diff --git a/MN.L10n/ExampleFiles/language-en-GB.json b/MN.L10n/ExampleFiles/language-en-GB.json deleted file mode 100644 index 85cd9ee..0000000 --- a/MN.L10n/ExampleFiles/language-en-GB.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "LanguageName": "English", - "Locale": "en-GB", - "PluralizationRules": [ "0", "1", "x" ], - "Phrases": { - "Hej Världen": { - "r": { - "x": "Hello World" - } - } - } -} \ No newline at end of file diff --git a/MN.L10n/ExampleFiles/language-sv-SE.json b/MN.L10n/ExampleFiles/language-sv-SE.json deleted file mode 100644 index 091605c..0000000 --- a/MN.L10n/ExampleFiles/language-sv-SE.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "LanguageName": "Svenska", - "Locale": "sv-SE", - "PluralizationRules": [ "0", "1", "x" ], - "Phrases": { - "Hej Världen": { - "r": { - "x": "Hej Världen" - } - } - } -} \ No newline at end of file diff --git a/MN.L10n/ExampleFiles/phrases.json b/MN.L10n/ExampleFiles/phrases.json deleted file mode 100644 index 5d951dc..0000000 --- a/MN.L10n/ExampleFiles/phrases.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "languages": [ "sv-SE", "en-GB" ], - "phrases": { - "Hej Världen": { - "comment": "Exempelfras som används i utbildningssyfte" - } - } -} \ No newline at end of file diff --git a/MN.L10n/FileProviders/FileDataProvider.cs b/MN.L10n/FileProviders/FileDataProvider.cs index b719204..978e583 100644 --- a/MN.L10n/FileProviders/FileDataProvider.cs +++ b/MN.L10n/FileProviders/FileDataProvider.cs @@ -10,29 +10,41 @@ public class FileDataProvider : IL10nDataProvider private string FilePath { get; set; } private string PhraseFile { get; set; } + private string LanguagesFile { get; set; } private string LanguageFile { get; set; } - public FileDataProvider(string path, string l10nFileName = "phrases.json", string l10nPhraseFileNameFormat = "language-{0}.json") + public FileDataProvider(string path, string l10nFileName = "phrases.json", string l10nPhraseFileNameFormat = "language-{0}.json", string l10nLanguagesFileName = "languages.json") { FilePath = path; PhraseFile = l10nFileName; + LanguagesFile = l10nLanguagesFileName; LanguageFile = l10nPhraseFileNameFormat; } public L10n LoadL10n() { var tp = new NGettext.Plural.Ast.AstTokenParser(); + var langPath = Path.Combine(FilePath, LanguagesFile); + List languages = new List { "default" }; + + if (File.Exists(langPath)) + { + var contents = File.ReadAllText(langPath); + languages = JSON.Deserialize>(contents); + } + var phrasePath = Path.Combine(FilePath, PhraseFile); L10n l10n; if (File.Exists(phrasePath)) { var l10nFileContents = File.ReadAllText(phrasePath); l10n = JSON.Deserialize(l10nFileContents, SerializerOptions); + l10n.Languages = languages; } else { l10n = new L10n { - Languages = new List { "default" } + Languages = languages }; File.WriteAllText(phrasePath, JSON.Serialize(l10n, SerializerOptions)); } diff --git a/MN.L10n/L10n.cs b/MN.L10n/L10n.cs index 2eea170..b8e375a 100644 --- a/MN.L10n/L10n.cs +++ b/MN.L10n/L10n.cs @@ -22,6 +22,8 @@ public static L10n CreateInstance(IL10nLanguageProvider langProvider, IL10nDataP Instance = l10n; return l10n; } + + [JilDirective(Ignore = true)] public List Languages { get; set; } = new List(); public Dictionary Phrases { get; set; } = new Dictionary(); diff --git a/MN.L10n/L10nBuildTask.cs b/MN.L10n/L10nBuildTask.cs index 3c9aa35..8662a14 100644 --- a/MN.L10n/L10nBuildTask.cs +++ b/MN.L10n/L10nBuildTask.cs @@ -20,7 +20,6 @@ public override bool Execute() var sourceDir = Environment.CurrentDirectory; Log.LogMessage(MessageImportance.High, "info l10n: L10n - beginning work: " + sourceDir); - Debugger.Break(); Stopwatch stw = new Stopwatch(); stw.Start(); diff --git a/MN.L10n/MN.L10n.csproj b/MN.L10n/MN.L10n.csproj index c91da33..d5f6d4f 100644 --- a/MN.L10n/MN.L10n.csproj +++ b/MN.L10n/MN.L10n.csproj @@ -12,8 +12,17 @@ Translation package https://github.com/MultinetInteractive/MN.L10n git © 20XX MultiNet Interactive AB - 1.0.101 + 1.0.107 True + ## 1.0.107 +- I kinda missed a semicolon in the targets-file.. + +## 1.0.106 +- Updated README + +## 1.0.105 +- Added separate file to store Languages in +- Files to store in Solution = languages.json and all language-{0}.json-files diff --git a/MN.L10n/build/MN.L10n.targets b/MN.L10n/build/MN.L10n.targets index 19c1b2e..43df53c 100644 --- a/MN.L10n/build/MN.L10n.targets +++ b/MN.L10n/build/MN.L10n.targets @@ -9,10 +9,10 @@ - + - + diff --git a/README.md b/README.md index 595e6d8..b00461a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# MN.L10n [![Build status](https://ci.appveyor.com/api/projects/status/y5uh8gvxm29v90rk?svg=true)](https://ci.appveyor.com/project/itssimple/mn-l10n) +# MN.L10n [![Build status](https://ci.appveyor.com/api/projects/status/y5uh8gvxm29v90rk?svg=true)](https://ci.appveyor.com/project/itssimple/mn-l10n) Translation-thingy for all our products You must implement your `IL10nLanguageProvider` and a custom `IFileResolver` (for javascript) yourself. :) (Basically just `string GetLanguage()` and `bool FileExists(string file)`) @@ -57,7 +57,7 @@ Response.Write("