-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from dotnet-campus/t/lvyi/first
Add initial project files.
- Loading branch information
Showing
49 changed files
with
1,896 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: .NET Core | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: windows-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
|
||
- name: Build with dotnet | ||
run: dotnet build --configuration Release | ||
|
||
- name: Test | ||
run: dotnet test --configuration Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# 去掉注释可以合并 master 分支自动打包 | ||
# 为什么不期望推送 master 自动打包?原因是打出来的 CBB 没有 Tag 不利于回滚找到代码 | ||
|
||
# name: publish nuget | ||
|
||
# on: | ||
# push: | ||
# branches: | ||
# - master | ||
|
||
# jobs: | ||
# build: | ||
|
||
# runs-on: windows-latest | ||
|
||
# steps: | ||
# - uses: actions/checkout@v1 | ||
|
||
# - name: Setup .NET Core | ||
# uses: actions/setup-dotnet@v1 | ||
# with: | ||
# dotnet-version: 3.1.300 | ||
|
||
# - name: Build with dotnet | ||
# run: | | ||
# dotnet build --configuration Release | ||
# dotnet pack --configuration Release --no-build | ||
|
||
# - name: Install Nuget | ||
# uses: nuget/setup-nuget@v1 | ||
# with: | ||
# nuget-version: '5.x' | ||
|
||
# - name: Add private GitHub registry to NuGet | ||
# run: | | ||
# nuget sources add -name github -Source https://nuget.pkg.github.com/dotnet-campus/index.json -Username dotnet-campus -Password ${{ secrets.GITHUB_TOKEN }} | ||
# - name: Push generated package to GitHub registry | ||
# run: | | ||
# nuget push .\bin\Release\*.nupkg -Source github -SkipDuplicate | ||
# nuget push .\bin\Release\*.nupkg -Source https://api.nuget.org/v3/index.json -SkipDuplicate -ApiKey ${{ secrets.NugetKey }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: publish nuget | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: windows-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
|
||
- name: Setup .NET Core | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: 8.0.x | ||
|
||
- name: Install dotnet tool | ||
run: dotnet tool install -g dotnetCampus.TagToVersion | ||
|
||
- name: Set tag to version | ||
run: dotnet TagToVersion -t ${{ github.ref }} | ||
|
||
- name: Build with dotnet | ||
run: dotnet build -c Release | ||
|
||
- name: Install Nuget | ||
uses: nuget/setup-nuget@v1 | ||
with: | ||
nuget-version: '6.x' | ||
|
||
- name: Add private GitHub registry to NuGet | ||
run: | | ||
nuget sources add -name github -Source https://nuget.pkg.github.com/dotnet-campus/index.json -Username dotnet-campus -Password ${{ secrets.GITHUB_TOKEN }} | ||
- name: Push generated package to GitHub registry | ||
run: | | ||
nuget push .\artifacts\package\release\*.nupkg -Source github -SkipDuplicate | ||
nuget push .\artifacts\package\release\*.nupkg -Source https://api.nuget.org/v3/index.json -SkipDuplicate -ApiKey ${{ secrets.NugetKey }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<Project> | ||
|
||
<Import Project="build\Version.props" /> | ||
|
||
<!-- 框架和语言信息 --> | ||
<PropertyGroup> | ||
<LangVersion>latest</LangVersion> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<ArtifactsPath>$(MSBuildThisFileDirectory)artifacts</ArtifactsPath> | ||
<RepositoryRoot>$(MSBuildThisFileDirectory)</RepositoryRoot> | ||
</PropertyGroup> | ||
|
||
<!--库信息 --> | ||
<PropertyGroup> | ||
<Description>使用源生成器为你的项目增加本地化源代码,使得你可以利用 IDE 的智能感知来使用多语言。</Description> | ||
<Authors>dotnet-campus</Authors> | ||
<Company>dotnet campus(.NET 职业技术学院)</Company> | ||
<Copyright>Copyright $([System.DateTime]::Now.ToString(`yyyy`)) © dotnet campus, All Rights Reserved.</Copyright> | ||
<RepositoryType>git</RepositoryType> | ||
<RepositoryUrl>https://github.com/dotnet-campus/dotnetCampus.SourceLocalizations</RepositoryUrl> | ||
<PackageProjectUrl>https://github.com/dotnet-campus/dotnetCampus.SourceLocalizations</PackageProjectUrl> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# dotnetCampus.SourceLocalizations | ||
|
||
| Build | NuGet | | ||
|--|--| | ||
|![](https://github.com/dotnet-campus/dotnetCampus.SourceLocalizations/workflows/.NET%20Core/badge.svg)|[![](https://img.shields.io/nuget/v/dotnetCampus.SourceLocalizations.svg)](https://www.nuget.org/packages/dotnetCampus.SourceLocalizations)| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<Version>0.1.0-alpha01</Version> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.0.31903.59 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnetCampus.Localizations", "src\dotnetCampus.Localizations\dotnetCampus.Localizations.csproj", "{9A8FEE27-F589-48E4-BF31-CC0D5CD4A3F0}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnetCampus.Localizations.Analyzer", "src\dotnetCampus.Localizations.Analyzer\dotnetCampus.Localizations.Analyzer.csproj", "{48BE5845-BF2F-48CD-8214-2418E72A9BFF}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{E407F54C-8E41-4F4E-B9BF-9864B6178E5F}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LocalizationSample", "samples\LocalizationSample\LocalizationSample.csproj", "{F330175F-FC20-4D42-921A-747AC296D1B9}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{4239BEE3-D480-4874-83E1-353B35F1BD86}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnetCampus.Localizations.Tests", "tests\dotnetCampus.Localizations.Tests\dotnetCampus.Localizations.Tests.csproj", "{3170B151-6A25-4321-BF09-EFC516E32F8D}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{6E0F9A76-51AE-49A7-B74C-CA194F6CD37C}" | ||
ProjectSection(SolutionItems) = preProject | ||
.gitattributes = .gitattributes | ||
.gitignore = .gitignore | ||
README.md = README.md | ||
Directory.Build.props = Directory.Build.props | ||
build\Version.props = build\Version.props | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{9A8FEE27-F589-48E4-BF31-CC0D5CD4A3F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{9A8FEE27-F589-48E4-BF31-CC0D5CD4A3F0}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{9A8FEE27-F589-48E4-BF31-CC0D5CD4A3F0}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{9A8FEE27-F589-48E4-BF31-CC0D5CD4A3F0}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{48BE5845-BF2F-48CD-8214-2418E72A9BFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{48BE5845-BF2F-48CD-8214-2418E72A9BFF}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{48BE5845-BF2F-48CD-8214-2418E72A9BFF}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{48BE5845-BF2F-48CD-8214-2418E72A9BFF}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{F330175F-FC20-4D42-921A-747AC296D1B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{F330175F-FC20-4D42-921A-747AC296D1B9}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{F330175F-FC20-4D42-921A-747AC296D1B9}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{F330175F-FC20-4D42-921A-747AC296D1B9}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{3170B151-6A25-4321-BF09-EFC516E32F8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{3170B151-6A25-4321-BF09-EFC516E32F8D}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{3170B151-6A25-4321-BF09-EFC516E32F8D}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{3170B151-6A25-4321-BF09-EFC516E32F8D}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
{F330175F-FC20-4D42-921A-747AC296D1B9} = {E407F54C-8E41-4F4E-B9BF-9864B6178E5F} | ||
{3170B151-6A25-4321-BF09-EFC516E32F8D} = {4239BEE3-D480-4874-83E1-353B35F1BD86} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\dotnetCampus.Localizations\dotnetCampus.Localizations.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<LocalizationFile Include="Localizations\**\*.yaml" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
A.A1: "Words" | ||
A.A2: "Error code: {errorCode:int}" | ||
A.A3: "Error: {error}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
A.A1: "文本" | ||
A.A2: "错误码:{errorCode:int}" | ||
A.A3: "错误:{error}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System.Collections.Frozen; | ||
using System.ComponentModel; | ||
using dotnetCampus.Localizations; | ||
|
||
namespace LocalizationSample; | ||
|
||
internal class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
} | ||
} | ||
|
||
[LocalizedConfiguration(Default = "zh-hans", Current = "en")] | ||
internal partial class Lang; | ||
|
||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public interface ILocalized_Root : ILocalizedStringProvider | ||
{ | ||
ILocalized_Root_A A => (ILocalized_Root_A)this; | ||
} | ||
|
||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public interface ILocalized_Root_A : ILocalizedStringProvider | ||
{ | ||
LocalizedString A1 => this.Get0("A.A1"); | ||
|
||
LocalizedString<int> A2 => this.Get1<int>("A.A2"); | ||
|
||
LocalizedString<object> A3 => this.Get1<object>("A.A3"); | ||
} | ||
|
||
public class Lang_ZhHans(ILocalized_Root? fallback) : ILocalized_Root, | ||
ILocalized_Root_A | ||
{ | ||
private readonly FrozenDictionary<string, string> _strings = new Dictionary<string, string> | ||
{ | ||
{ "A.A1", "文字" }, | ||
{ "A.A2", "错误码:{0}" }, | ||
{ "A.A3", "错误:{0}" }, | ||
}.ToFrozenDictionary(); | ||
|
||
public string this[string key] => _strings[key] ?? fallback![key]; | ||
|
||
public string IetfLanguageTag => "zh-hans"; | ||
} | ||
|
||
public class Lang_En(ILocalized_Root? fallback) : ILocalized_Root, | ||
ILocalized_Root_A | ||
{ | ||
private readonly FrozenDictionary<string, string> _strings = new Dictionary<string, string> | ||
{ | ||
{ "A.A1", "Words" }, | ||
{ "A.A2", "Error code: {0}" }, | ||
{ "A.A3", "Error: {0}" }, | ||
}.ToFrozenDictionary(); | ||
|
||
public string this[string key] => _strings[key] ?? fallback![key]; | ||
|
||
public string IetfLanguageTag => "en"; | ||
} |
18 changes: 18 additions & 0 deletions
18
src/dotnetCampus.Localizations.Analyzer/Assets/Analyzers/LspPlaceholder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
global using dotnetCampus.Localizations.Assets.Analyzers; | ||
using dotnetCampus.Localizations.Assets.Templates; | ||
|
||
namespace dotnetCampus.Localizations.Assets.Analyzers; | ||
|
||
/// <summary> | ||
/// 为生成 <see cref="Localization"/> 的分部类的部分待填充代码提供占位符。 | ||
/// </summary> | ||
/// <param name="ietfLanguageTag"></param> | ||
/// <param name="fallback"></param> | ||
public class LspPlaceholder(string ietfLanguageTag, ILocalized_Root? fallback) : ILocalized_Root | ||
{ | ||
/// <inheritdoc /> | ||
public string IetfLanguageTag => ietfLanguageTag; | ||
|
||
/// <inheritdoc /> | ||
public string this[string key] => fallback![key]; | ||
} |
15 changes: 15 additions & 0 deletions
15
src/dotnetCampus.Localizations.Analyzer/Assets/Templates/ILocalized_Root.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#nullable enable | ||
|
||
using ILocalizedStringProvider = global::dotnetCampus.Localizations.ILocalizedStringProvider; | ||
using LocalizedString = global::dotnetCampus.Localizations.LocalizedString; | ||
|
||
namespace dotnetCampus.Localizations.Assets.Templates; | ||
|
||
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] | ||
public interface ILocalized_Root : ILocalizedStringProvider | ||
{ | ||
// <FLAG> | ||
// ILocalized_Root_A A => (ILocalized_Root_A)this; | ||
// LocalizedString A1 => this.Get0("A.A1"); | ||
// </FLAG> | ||
} |
16 changes: 16 additions & 0 deletions
16
src/dotnetCampus.Localizations.Analyzer/Assets/Templates/Localization.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#nullable enable | ||
|
||
namespace dotnetCampus.Localizations.Assets.Templates; | ||
|
||
partial class Localization | ||
{ | ||
/// <summary> | ||
/// 获取默认的本地化字符串集。 | ||
/// </summary> | ||
public static ILocalized_Root Default { get; } = new LspPlaceholder("default", null); | ||
|
||
/// <summary> | ||
/// 获取当前的本地化字符串集。 | ||
/// </summary> | ||
public static ILocalized_Root Current { get; private set; } = new LspPlaceholder("current", null); | ||
} |
25 changes: 25 additions & 0 deletions
25
src/dotnetCampus.Localizations.Analyzer/Assets/Templates/LocalizationValues.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#nullable enable | ||
|
||
using global::System.Collections.Frozen; | ||
|
||
namespace dotnetCampus.Localizations.Assets.Templates; | ||
|
||
/// <inheritdoc /> | ||
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] | ||
public class LocalizationValues(ILocalized_Root? fallback) : ILocalized_Root | ||
{ | ||
/// <inheritdoc /> | ||
public string IetfLanguageTag => "default"; | ||
|
||
/// <inheritdoc /> | ||
public string this[string key] => _strings[key] ?? fallback![key]; | ||
|
||
private readonly FrozenDictionary<string, string> _strings = new Dictionary<string, string> | ||
{ | ||
// <FLAG> | ||
{ "A.A1", "文字" }, | ||
{ "A.A2", "错误码:{0}" }, | ||
{ "A.A3", "错误:{0}" }, | ||
// </FLAG> | ||
}.ToFrozenDictionary(); | ||
} |
Oops, something went wrong.