/// <summary>Render the Pseudolocalization for the selected language.</summary> private void RenderPseudolocalization() { //display an error if there is no input file if (englishJSONAsset == null) { Debug.LogErrorFormat("No input file."); return; } //load the json file as a dictionary TextAsset asset = englishJSONAsset as TextAsset; Dictionary <string, string> inputJSON = JSONSerializer.FromJson <Dictionary <string, string> >(asset.text); Dictionary <string, string> outputJSON = new Dictionary <string, string>(); //loop through each kvp foreach (KeyValuePair <string, string> kvp in inputJSON) { //determine the pseudotranslation string englishText = kvp.Value; int numberOfRandomSpecialCharactersToGenerate = PseudotranslationLengthForText(englishText) - englishText.Length; string pseudoTranslation = string.Format("{0}|{1}", AddSpecialCharactersToText(englishText), GenerateXRandomSpecialCharacters(numberOfRandomSpecialCharactersToGenerate)); //add to output dictionary outputJSON[kvp.Key] = pseudoTranslation; } //convert the dictionary to json string outputJSONString = JSONSerializer.ToJson <Dictionary <string, string> >(outputJSON); //determine a path for the output file string path = string.Format("{0}/{1}Pseudo.json", Path.GetFullPath(Directory.GetParent(AssetDatabase.GetAssetPath(englishJSONAsset)).FullName), langugage.ToString()); //save the file to disk File.WriteAllText(path, outputJSONString); //update asset database AssetDatabase.Refresh(); AssetDatabase.SaveAssets(); }
public void LoadDatabase() { textDatabase = JSONSerializer.FromJson <Dictionary <string, string> >(supportedLanguages[SettingsGame.instance.localizedLanguage].jsonDatabase.text); isLoaded = true; }
/// <summary>Loads the localization database.</summary> private void LoadDatabase() { Debug.Log("LoadDatabase"); textDatabase = JSONSerializer.FromJson <Dictionary <string, string> >(supportedLanguages[SettingsManager.instance.localizedLanguage].jsonDatabase.text); isLoaded = true; }