コード例 #1
0
        private static void OnCurrentLanguageChanged()
        {
            var currentLanguage = Language.currentLanguage;

            if (currentLanguage is null)
            {
                return;
            }

            _originalTokens.Clear();
            _originalTokens.AddRange(currentLanguage.stringsByToken);

            currentLanguage.stringsByToken = currentLanguage.stringsByToken.ReplaceAndAddRange(GenericTokens);

            if (LanguageSpecificTokens.TryGetValue(currentLanguage.name, out var languageSpecificDic))
            {
                currentLanguage.stringsByToken = currentLanguage.stringsByToken.ReplaceAndAddRange(languageSpecificDic);
            }

            GenericOverlays.Clear();
            LanguageSpecificOverlays.Clear();
            onSetupLanguageOverlays?.Invoke();

            currentLanguage.stringsByToken = currentLanguage.stringsByToken.ReplaceAndAddRange(GenericOverlays);

            if (LanguageSpecificOverlays.TryGetValue(currentLanguage.name, out var languageSpecificOverlayDic))
            {
                currentLanguage.stringsByToken = currentLanguage.stringsByToken.ReplaceAndAddRange(languageSpecificOverlayDic);
            }
        }
コード例 #2
0
 private void LanguageOverlay_onSetupLanguageOverlays()
 {
     foreach (var overlay in overlays)
     {
         Dictionary <string, string> targetDict;
         if (overlay.isGeneric)
         {
             targetDict = GenericOverlays;
         }
         else
         {
             if (!LanguageSpecificOverlays.ContainsKey(overlay.lang))
             {
                 LanguageSpecificOverlays.Add(overlay.lang, new Dictionary <string, string>());
             }
             targetDict = LanguageSpecificOverlays[overlay.lang];
         }
         targetDict[overlay.key] = overlay.value;
     }
 }