コード例 #1
0
 static string GetLanguageFileContents(string sheetTitle)
 {
     if (LocalizationServerManager.Instance.HasLanguageFile(currentLanguage.ToString(), sheetTitle))
     {
         return(LocalizationServerManager.Instance.GetLanguageFileContents(currentLanguage.ToString(), sheetTitle));
     }
     else
     {
         TextAsset ta = (TextAsset)Resources.Load("Languages/" + currentLanguage + "_" + sheetTitle, typeof(TextAsset));
         return(ta.text);
     }
 }
コード例 #2
0
    public AudioClip GetAudioByName(SoundType soundType, LanguageCode lang, string soundName)
    {
        AudioClip fetchAudio = null;

        string langKey       = lang.ToString();
        string soundToSearch = soundName + "_" + langKey;

        try
        {
            switch (soundType)
            {
            case SoundType.Questions:

                fetchAudio = QuestionAudioClips[langKey][soundToSearch];

                break;

            case SoundType.Subtitles:

                fetchAudio = SubtitlesAudioClips[langKey][soundToSearch];
                break;
            }
        }
        catch (Exception)
        {
            fetchAudio = null;

            throw;
        }


        return(fetchAudio);
    }
コード例 #3
0
    public static Dictionary <int, string> ReadErrorTextData(LanguageCode lang)
    {
        Dictionary <int, string> _dic_ErrorTranslateText = new Dictionary <int, string>();

        TextAsset _txtAsset = Resources.Load(string.Format("TextData/{0}/{1}", lang.ToString(), "ErrorCode")) as TextAsset;

        // LanguageCOde 정의했지만 해당언어 데이터가 없는 경우 리턴 떄리자
        if (_txtAsset == null)
        {
            return(_dic_ErrorTranslateText);
        }

        string _jsonData = _txtAsset.text;


        object        _jsonObj = MiniJSON.Json.Deserialize(_jsonData);
        List <object> _lstData = (List <object>)_jsonObj;

#if UNITY_EDITOR
        if (_lstData.Count == 0 || _lstData == null)
        {
            Debug.LogError("TEXT DATA IS NULL OR EMPTY");
        }
#endif
        int _idx = 0;

        for (int i = 0; i < _lstData.Count; i++)
        {
            Dictionary <string, object> _dicData = (Dictionary <string, object>)_lstData[i];
            _idx = Convert.ToInt16(_dicData[JsonKey.idx]);
            _dic_ErrorTranslateText[_idx] = Convert.ToString(_dicData[JsonKey.TEXT]);
        }

        return(_dic_ErrorTranslateText);
    }
コード例 #4
0
ファイル: Translator.cs プロジェクト: cacttus/artpop
        public static Phrase FindPhrase(string in_selected_lang, LanguageCode code)
        {
            //For the currently selected language find the translated phrase.
            string err = "No translation for '"
                         + in_selected_lang
                         + "' exists for the currently seelcted lang: '"
                         + code.ToString() + "'.";

            Dictionary <int, Phrase> dict = null;

            if (Phrases.Lexicon.TryGetValue(code, out dict) == false)
            {
                Globals.LogError(err);

                //Return bad phrase.
                return(null);
            }

            Phrase trans = null;

            if (dict.TryGetValue(in_selected_lang.GetHashCode(), out trans) == false)
            {
                Globals.LogError(err);
                return(null);
            }

            return(trans);
        }
コード例 #5
0
        private static string GetDescription(LanguageCode value)
        {
            FieldInfo field = typeof(LanguageCode).GetField(value.ToString());

            return(field.GetCustomAttributes(typeof(DescriptionAttribute), false)
                   .Cast <DescriptionAttribute>()
                   .Select(x => x.Description)
                   .FirstOrDefault());
        }
コード例 #6
0
        private string GetName(List <VmJsonTypeName> names, LanguageCode code)
        {
            string result = "";

            if (names != null)
            {
                result = names.Where(x => x.Language == code.ToString()).Select(x => x.Name).FirstOrDefault();
            }
            return(result);
        }
コード例 #7
0
ファイル: LanguageValue.cs プロジェクト: ewin66/Arya
        public static string StringValue(this LanguageCode lc)
        {
            switch (lc)
            {
            case LanguageCode.Facet:
                return("00");

                break;

            default:
                return(lc.ToString().ToLower());
            }
        }
コード例 #8
0
        override protected PhraseData CreateData(Dictionary <string, object> dict, DatabaseObject db,
                                                 LanguageCode language)
        {
            var data = new PhraseData();

            data.Id     = ToString(dict["Id"]);
            data.Active = (ToInt(dict["Active"]) == 1);
            if (!data.Active)
            {
                return(null);               // Skip this data if inactive
            }
            string langKey = language.ToString().ToUpper()[0] + language.ToString().Substring(1);

            data.Text       = ToString(dict[langKey]);
            data.Category   = ParseEnum <PhraseDataCategory>(data, dict["Category"]);
            data.Linked     = ToString(dict["Linked"]);
            data.Words      = ParseIDArray <WordData, WordTable>(data, (string)dict["Words"], db.GetWordTable());
            data.Answers    = ParseIDArray <WordData, WordTable>(data, (string)dict["Answers"], db.GetWordTable());
            data.Complexity = ToFloat(dict["Complexity"]);

            return(data);
        }
コード例 #9
0
    private IEnumerator FetchAndReadLanguageJson()
    {
        string        languagesFilePath = Application.streamingAssetsPath + "/LanguageFiles";
        DirectoryInfo directoryInfo     = new DirectoryInfo(languagesFilePath);

        FileInfo[] allFiles = directoryInfo.GetFiles("*.json");

        LanguagesTable = new Hashtable();

        foreach (var item in allFiles)
        {
            using (UnityWebRequest languageFileReader = UnityWebRequest.Get(item.FullName))
            {
                yield return(languageFileReader.SendWebRequest());

                if (languageFileReader.isNetworkError || languageFileReader.isHttpError)
                {
                    Debug.LogWarning("Couldn't found JSON file for: " + item.FullName);
                }
                else
                {
                    JObject languageJson = JObject.Parse(languageFileReader.downloadHandler.text);

                    string lang = languageJson["Language"].ToString();

                    LanguageCode thisLangCode = ReturnLanguageCodeFromString(lang);
                    LanguagesTable[thisLangCode] = new Hashtable();

                    Hashtable subs = languageJson["Subtitles"].ToObject <Hashtable>();

                    foreach (DictionaryEntry entry in subs)
                    {
                        if (!(LanguagesTable[thisLangCode] as Hashtable).ContainsKey(entry.Key))
                        {
                            (LanguagesTable[thisLangCode] as Hashtable).Add(entry.Key, entry.Value);
                        }
                    }


                    DebugConsole.instance.Languages.text += thisLangCode.ToString() + "\n";
                }
            }
        }


#if UNITY_STANDALONE
        Debug.Log("Translations loaded");
#endif

        LANGUAGESREADY = true;
    }
コード例 #10
0
        private int GetCodeIndex(LanguageCode code)
        {
            int codeIndex = 0;

            for (int i = 0; i < m_LanguageInfoList.Count; i++)
            {
                if (code.ToString().Equals(m_LanguageInfoList[i].LanguageCodeName))
                {
                    codeIndex = i;
                    break;
                }
            }

            return(codeIndex);
        }
コード例 #11
0
 private static VmPhone CreateVm(ServiceChargeTypeEnum?serviceChargeType, PhoneNumberTypeEnum?phoneNumberType, LanguageCode?languageCode)
 {
     return(new VmPhone
     {
         ChargeDescription = "description",
         Number = "456789",
         DialCode = new VmDialCode()
         {
             Id = new Guid()
         },
         AdditionalInformation = "info",
         ChargeType = serviceChargeType?.ToString().GetGuid() ?? Guid.Empty,
         TypeId = phoneNumberType?.ToString().GetGuid() ?? Guid.Empty,
         LanguageId = languageCode?.ToString().GetGuid() ?? Guid.Empty
     });
 }
コード例 #12
0
        public override string ToString()
        {
            var localizedData = _translatable.GetI18N();

            if (localizedData == null)
            {
                return(_fullPath);
            }

            if (_hasLanguageSet == false)
            {
                return(localizedData.GetText(_fullPath));
            }

            return(localizedData.GetText(_fullPath, _language.ToString()));
        }
コード例 #13
0
ファイル: I18N.cs プロジェクト: JPedroMPF/Showcase
        /// <summary>
        /// Change current language.
        /// Set default if language not initialized or recognized.
        /// </summary>
        /// <param name="langCode">Language code</param>
        public void setLanguage(LanguageCode langCode)
        {
            if (_langs.ContainsKey(langCode))
            {
                _gameLang = langCode;
            }
            else
            {
                _gameLang = _defaultLang;
                Debug.LogError(string.Format("Language {0} not recognized! Using default language.", langCode));
            }

            PlayerPrefs.SetString(GAME_LANG, _gameLang.ToString());

            if (OnLanguageChanged != null)
            {
                OnLanguageChanged(_gameLang);
            }

            if (_useCustomFonts)
            {
                I18NFonts newFont = null;
                _currentCustomFont = null;
                if (_langFonts != null && _langFonts.Count > 0)
                {
                    foreach (I18NFonts f in _langFonts)
                    {
                        if (f.lang == _gameLang)
                        {
                            newFont            = f;
                            _currentCustomFont = f;
                            break;
                        }
                    }
                }

                if (OnFontChanged != null)
                {
                    OnFontChanged(newFont);
                }
            }
            else
            {
                _currentCustomFont = null;
            }
        }
コード例 #14
0
ファイル: LanguageEditor.cs プロジェクト: troyanich/Test
    void SaveSettingsFile()
    {
        if (settings == null)
        {
            settings = (LocalizationSettings)ScriptableObject.CreateInstance(typeof(LocalizationSettings));
            string settingsPath = Path.GetDirectoryName(settingsAssetPath);
            if (!Directory.Exists(settingsPath))
            {
                Directory.CreateDirectory(settingsPath);
                AssetDatabase.ImportAsset(settingsPath);
            }

            AssetDatabase.CreateAsset(settings, settingsAssetPath);
        }
        settings.defaultLangCode             = langCode.ToString();
        settings.useSystemLanguagePerDefault = useSystemLang;
        EditorUtility.SetDirty(settings);
    }
コード例 #15
0
        public LocalizationManager(TextAsset localization, List <LanguageInfo> LanguageInfoList)
        {
            m_LanguageInfoList = LanguageInfoList;

            LanguageCode code;

            if (PlayerPrefs.HasKey(LocalizatioCode))
            {
                string codeName = PlayerPrefs.GetString(LocalizatioCode, defaultCode.ToString());
                code = (LanguageCode)Enum.Parse(typeof(LanguageCode), codeName);
            }
            else
            {
                code = GetSystemLanguageCode();
            }

            LocalizatioCodeIndex = GetCodeIndex(code);

            ReadCSV(localization);
        }
コード例 #16
0
        /// <summary>
        /// Serializes with the specified writer.
        /// </summary>
        /// <param name="writer">Writer.</param>
        public override void Serialize(XmlWriter writer)
        {
            writer.WriteStartElement("DefineFont2Tag");
            writer.WriteAttributeString("FontId", fontId.ToString());

            bool fontFlagsWideCodes   = this.glyphShapesTable.IsWideCodes;
            bool fontFlagsWideOffsets = HasWideOffsets();
            bool fontFlagsHasLayout   = HasLayoutInfo();

            writer.WriteElementString("FontFlagsHasLayout", fontFlagsHasLayout.ToString());
            writer.WriteElementString("FontFlagsShiftJIS", fontFlagsShiftJIS.ToString());
            writer.WriteElementString("FontFlagsANSI", fontFlagsANSI.ToString());
            writer.WriteElementString("FontFlagsWideOffsets", fontFlagsWideOffsets.ToString());
            writer.WriteElementString("FontFlagsWideCodes", fontFlagsWideCodes.ToString());
            writer.WriteElementString("FontFlagsItalic", fontFlagsItalic.ToString());
            writer.WriteElementString("FontFlagsBold", fontFlagsBold.ToString());
            writer.WriteElementString("LanguageCode", languageCode.ToString());
            writer.WriteElementString("FontNameLength", fontName.Length.ToString());
            writer.WriteElementString("FontName", fontName.ToString());

            //if (offsetTable != null)
            //	writer.WriteElementString("OffsetTableLenght", offsetTable.Length.ToString());
            //writer.WriteElementString("CodeTableOffset", codeTableOffset.ToString());

            if (glyphShapesTable != null)
            {
                glyphShapesTable.Serialize(writer);
            }

            if (fontFlagsHasLayout)
            {
                writer.WriteElementString("FontAscent", fontAscent.ToString());
                writer.WriteElementString("FontDescent", fontDescent.ToString());
                writer.WriteElementString("FontLeading", fontLeading.ToString());
                writer.WriteElementString("FontAdvanceTable", fontAdvanceTable.Count.ToString());
                fontBoundsTable.Serialize(writer);
                fontKerningTable.Serialize(writer);
            }
            writer.WriteEndElement();
        }
コード例 #17
0
    public static Dictionary <int, string> ReadTextData(LanguageCode _lang)
    {
        // 지역 transtext 컬랙션
        Dictionary <int, string> _dic_TranslateText = new Dictionary <int, string>();

        string    _path    = string.Format("TextData/{0}/{1}", _lang.ToString(), "TextData");
        TextAsset _txtAset = Resources.Load(_path) as TextAsset;

        // LanguageCOde 정의했지만 데이터가 없는 경우 리턴 떄리자
        if (_txtAset == null)
        {
            return(_dic_TranslateText);
        }

        string _jsonData = _txtAset.text;

        object        _jsonObj = MiniJSON.Json.Deserialize(_jsonData);  // 라이브러리 json 파서
        List <object> _lstData = (List <object>)_jsonObj;


#if UNITY_EDITOR
        if (_lstData.Count == 0 || _lstData == null)
        {
            Debug.LogError("TEXT DATA IS NULL OR EMPTY");
        }
#endif
        int _idx = 0;

        for (int i = 0; i < _lstData.Count; i++)
        {
            Dictionary <string, object> _dicData = (Dictionary <string, object>)_lstData[i];

            _idx = Convert.ToInt32(_dicData[JsonKey.IDX]);

            string _text = Convert.ToString(_dicData[JsonKey.TEXT]);

            //정보담기
            _dic_TranslateText[_idx] = _text;


            /*int _mainKnd = _idx >> 7; // 인덱스 번호를 2진수 비트연산으로 대분류 번호를 추출
             * int _subKnd = (_idx & ((1 << 7) - 1));// ((1<<7)-1) 클리어라 생각... idx 추출
             *
             * switch (_mainKnd)
             * {
             *      case 0: TimeText[_subKnd] = _text; break;
             *      case 1: ItTpText[_subKnd] = _text; break;
             * }
             */

            //switch (_TrText)
            //{
            //    case TRANSLATE_TEXT.Combat: Dic_TranslateText[_TrText] = _text; break;
            //    case TRANSLATE_TEXT.Store: Dic_TranslateText[_TrText] = _text; break;
            //    case TRANSLATE_TEXT.Clan: Dic_TranslateText[_TrText] = _text; break;
            //    case TRANSLATE_TEXT.Formation: Dic_TranslateText[_TrText] = _text; break;
            //}
        }         // end of for


        //반환
        return(_dic_TranslateText);
    }
コード例 #18
0
ファイル: LanguageCache.cs プロジェクト: mvirenius/ptv-1.7
 public Guid Get(LanguageCode key)
 {
     return(this.cacheData[key.ToString()]);
 }
コード例 #19
0
ファイル: LanguageCache.cs プロジェクト: mvirenius/ptv-1.7
 public bool Filter(Guid languageId, LanguageCode filterBy)
 {
     return(languageId == this.cacheData[filterBy.ToString()]);
 }
コード例 #20
0
        /// <summary>
        /// Saves the current configuration to CONFIGFILE.
        /// </summary>
        public virtual void Save()
        {
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent      = true;
            settings.IndentChars = "  ";

            // init writer
            XmlWriter writer = XmlWriter.Create(ConfigFile, settings);

            // begin
            writer.WriteStartDocument();
            writer.WriteStartElement(XMLTAG_CONFIGURATION);

            /******************************************************************************/
            // PART I: RESOURCES

            writer.WriteStartElement(XMLTAG_RESOURCES);
            writer.WriteAttributeString(XMLATTRIB_VERSION, ResourcesVersion.ToString());
            writer.WriteAttributeString(XMLATTRIB_PATH, ResourcesPath.ToString().ToLower());
            writer.WriteAttributeString(XMLATTRIB_PRELOADROOMS, PreloadRooms.ToString().ToLower());
            writer.WriteAttributeString(XMLATTRIB_PRELOADOBJECTS, PreloadObjects.ToString().ToLower());
            writer.WriteAttributeString(XMLATTRIB_PRELOADROOMTEXTURES, PreloadRoomTextures.ToString().ToLower());
            writer.WriteAttributeString(XMLATTRIB_PRELOADSOUND, PreloadSound.ToString().ToLower());
            writer.WriteAttributeString(XMLATTRIB_PRELOADMUSIC, PreloadMusic.ToString().ToLower());
            writer.WriteEndElement();

            /******************************************************************************/
            // PART II: Connections

            writer.WriteStartElement(XMLTAG_CONNECTIONS);
            writer.WriteAttributeString(XMLATTRIB_SELECTEDINDEX, SelectedConnectionIndex.ToString());

            for (int i = 0; i < connections.Count; i++)
            {
                // connection
                writer.WriteStartElement(XMLTAG_CONNECTION);
                writer.WriteAttributeString(XMLATTRIB_NAME, connections[i].Name);
                writer.WriteAttributeString(XMLATTRIB_HOST, connections[i].Host);
                writer.WriteAttributeString(XMLATTRIB_PORT, connections[i].Port.ToString());
                writer.WriteAttributeString(XMLATTRIB_STRINGDICTIONARY, connections[i].StringDictionary);
                writer.WriteAttributeString(XMLATTRIB_USERNAME, connections[i].Username);
                writer.WriteAttributeString(XMLATTRIB_PASSWORD, String.Empty);
                writer.WriteAttributeString(XMLATTRIB_CHARACTER, connections[i].Character);

                // ignorelist
                writer.WriteStartElement(XMLTAG_IGNORELIST);
                for (int j = 0; j < connections[i].IgnoreList.Count; j++)
                {
                    writer.WriteStartElement(XMLTAG_IGNORE);
                    writer.WriteAttributeString(XMLATTRIB_NAME, connections[i].IgnoreList[j]);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();

                // groups
                writer.WriteStartElement(XMLTAG_GROUPS);
                foreach (Group group in connections[i].Groups)
                {
                    writer.WriteStartElement(XMLTAG_GROUP);
                    writer.WriteAttributeString(XMLATTRIB_NAME, group.Name);

                    foreach (GroupMember member in group.Members)
                    {
                        writer.WriteStartElement(XMLTAG_MEMBER);
                        writer.WriteAttributeString(XMLATTRIB_NAME, member.Name);
                        writer.WriteEndElement();
                    }

                    writer.WriteEndElement();
                }
                writer.WriteEndElement();

                writer.WriteEndElement();
            }

            writer.WriteEndElement();

            /******************************************************************************/
            // PART III: Language

            writer.WriteStartElement(XMLTAG_LANGUAGE);
            writer.WriteAttributeString(XMLATTRIB_VALUE, language.ToString());
            writer.WriteEndElement();

            /******************************************************************************/
            // PART IV: Aliases

            writer.WriteStartElement(XMLTAG_ALIASES);

            for (int i = 0; i < aliases.Count; i++)
            {
                // alias
                writer.WriteStartElement(XMLTAG_ALIAS);
                writer.WriteAttributeString(XMLATTRIB_KEY, aliases[i].Key);
                writer.WriteAttributeString(XMLATTRIB_VALUE, aliases[i].Value);
                writer.WriteEndElement();
            }

            writer.WriteEndElement();

            /******************************************************************************/

            // let deriving classes write their stuff
            WriteXml(writer);

            // end
            writer.WriteEndElement();
            writer.WriteEndDocument();

            // close writer
            writer.Close();
        }
コード例 #21
0
 public Guid Get(LanguageCode key)
 {
     return(Get(key.ToString()));
 }
コード例 #22
0
 public string GetLocalizedString(LanguageCode identifier) => identifier.ToString();
コード例 #23
0
 public FakeHostedPayment SetPayPageLanguageCode(LanguageCode languageCode)
 {
     LanguageCode = languageCode.ToString().ToLower();
     return this;
 }
コード例 #24
0
 public FakeHostedPayment SetPayPageLanguageCode(LanguageCode languageCode)
 {
     LanguageCode = languageCode.ToString().ToLower();
     return(this);
 }
コード例 #25
0
 /// <summary>
 /// 设置语言
 /// </summary>
 /// <param name="code"></param>
 public void SetLanguage(LanguageCode code)
 {
     LocalizatioCodeIndex = GetCodeIndex(code);
     PlayerPrefs.SetString(LocalizatioCode, code.ToString());
     LanguageEvent?.Invoke();
 }
コード例 #26
0
 public PackagedUserProfile(LiteracyProfile u, UserPreferences p, LanguageCode l)
 {
     userProblems = u; preferences = p; language = l.ToString();
 }
コード例 #27
0
 public PaymentMethodPayment SetPayPageLanguageCode(LanguageCode languageCode)
 {
     LanguageCode = languageCode.ToString().ToLower();
     return this;
 }
コード例 #28
0
        private void LocalizedContentManager_OnLanguageChange(LanguageCode code)
        {
            String cultureString = code.ToString();

            SpecificCulture = CultureInfo.CreateSpecificCulture(cultureString);
        }
コード例 #29
0
 public DifficultiesDescription( LanguageArea[] p, Difficulty[][] d, LanguageCode l)
 {
     problemsIndex=p;problems=d;language=l.ToString();
 }
コード例 #30
0
 public ITranslationDefinitions <ServiceChannelVersioned, TOut> AddWebPagesDefinition <TOut>(ITranslationDefinitions <ServiceChannelVersioned, TOut> definition, LanguageCode languageCode) where TOut : IWebPages
 {
     return(definition.AddCollection(i => i.WebPages.OrderBy(x => x.WebPage.OrderNumber).ThenBy(x => x.WebPage.Created).Where(x => languageCache.Get(languageCode.ToString()) == x.WebPage.LocalizationId), o => o.WebPages));
 }
コード例 #31
0
        public async Task SetLanguageAsync(LanguageCode language)
        {
            await _cache.InvalidateAll();

            await _cache.InsertObject(nameof(LanguageCode), language.ToString(), null);
        }
コード例 #32
0
 void SaveSettingsFile()
 {
     settings.defaultLangCode             = langCode.ToString();
     settings.useSystemLanguagePerDefault = useSystemLang;
     EditorUtility.SetDirty(settings);
 }
コード例 #33
0
 public PaymentMethodPayment SetPayPageLanguageCode(LanguageCode languageCode)
 {
     LanguageCode = languageCode.ToString().ToLower();
     return(this);
 }
コード例 #34
0
ファイル: Dialogues.cs プロジェクト: felixsoum/TriggerEvent
 private void Awake()
 {
     DialogueDao.DatabasePath = "URI=file:" + Application.dataPath + "/Databases/Dialogues.db";
     dialogueDictionary       = DialogueDao.GetAll(languageCode.ToString().ToLower());
 }