public void Setup()
 {
     m_LocaleProvider = new TestLocaleProvider();
     m_LocaleProvider.AddLocale(m_English   = Locale.CreateLocale("en"));
     m_LocaleProvider.AddLocale(m_EnglishGB = Locale.CreateLocale("en-GB"));
     m_LocaleProvider.AddLocale(m_Japanese  = Locale.CreateLocale("ja"));
 }
        void Start()
        {
            var localizationSettings = LocalizationSettings.GetInstanceDontCreateDefault();

            // Use included settings if one is available.
            if (useActiveLocalizationSettings && localizationSettings != null)
            {
                Debug.Log("Using included localization data");
                return;
            }

            Debug.Log("Creating default localization data");

            // Create our localization settings. If a LocalizationSettings asset has been created and configured in the editor then we can leave this step out.
            localizationSettings = LocalizationSettings.CreateDefault();

            // Replace the default Locales Provider with something we can manage locally for the example
            var simpleLocalesProvider = ScriptableObject.CreateInstance <SimpleLocalesProvider>();

            localizationSettings.SetAvailableLocales(simpleLocalesProvider);

            // Add the locales we support
            simpleLocalesProvider.AddLocale(Locale.CreateLocale(new LocaleIdentifier(SystemLanguage.Arabic)));
            simpleLocalesProvider.AddLocale(Locale.CreateLocale(new LocaleIdentifier(SystemLanguage.English)));
            simpleLocalesProvider.AddLocale(Locale.CreateLocale(new LocaleIdentifier(SystemLanguage.French)));
            simpleLocalesProvider.AddLocale(Locale.CreateLocale(new LocaleIdentifier(SystemLanguage.German)));
            simpleLocalesProvider.AddLocale(Locale.CreateLocale(new LocaleIdentifier(SystemLanguage.Japanese)));
            simpleLocalesProvider.AddLocale(Locale.CreateLocale(CultureInfo.InvariantCulture));

            // Set English to be our default
            localizationSettings.OnSelectedLocaleChanged += OnSelectedLocaleChanged;
            LocalizationSettings.Instance = localizationSettings;
        }
Beispiel #3
0
        public IEnumerator ListViewUpdatesWhenLocaleIsAdded()
        {
            WrapperWindow window = GetWindow((wnd) =>
            {
                // Perform an update
                var height = m_PropertyDrawer.GetPropertyHeight(m_Property, GUIContent.none);
                m_PropertyDrawer.OnGUI(new Rect(wnd.position.x, wnd.position.y, wnd.position.width, height), m_Property, GUIContent.none);

                // Add a new Locale
                var newLocale = Locale.CreateLocale(SystemLanguage.Hebrew);
                LocalizationEditorSettings.AddLocale(newLocale);

                // Update again, it should not contain the new element
                height = m_PropertyDrawer.GetPropertyHeight(m_Property, GUIContent.none);
                m_PropertyDrawer.OnGUI(new Rect(wnd.position.x, wnd.position.y, wnd.position.width, height), m_Property, GUIContent.none);

                Assert.That(m_FakeLocaleProvider.TestLocales, Does.Contain(newLocale));
                CheckListViewContainsProjectLocales();

                return(true);
            });

            yield return(null);

            Assert.That(window.TestCompleted, Is.True);
        }
        public IEnumerator ListViewUpdatesWhenLocaleIsAdded()
        {
            bool          localeAdded = false;
            WrapperWindow window      = GetWindow((wnd) =>
            {
                // Add a new Locale
                if (!localeAdded)
                {
                    var newLocale = Locale.CreateLocale(SystemLanguage.Hebrew);
                    LocalizationEditorSettings.AddLocale(newLocale);
                    Assert.That(m_FakeLocaleProvider.TestLocales, Does.Contain(newLocale));
                    localeAdded = true;
                    return(false);
                }
                else
                {
                    CheckListContainsProjectLocales(wnd);
                    return(true);
                }
            });

            var root = m_PropertyDrawer.CreatePropertyGUI(m_ScriptableObject.FindProperty("provider"));

            window.rootVisualElement.Add(root);

            yield return(null);

            Assert.That(window.TestCompleted, Is.True);
        }
Beispiel #5
0
 public void Setup()
 {
     m_Arabic  = Locale.CreateLocale(SystemLanguage.Arabic);
     m_Basque  = Locale.CreateLocale(SystemLanguage.Basque);
     m_Catalan = Locale.CreateLocale(SystemLanguage.Catalan);
     m_French  = Locale.CreateLocale(SystemLanguage.French);
     m_Pseudo  = PseudoLocale.CreatePseudoLocale();
 }
        void Start()
        {
            // Create a locale to represent Japanese.
            var localeId = new LocaleIdentifier(SystemLanguage.Japanese);
            var locale   = Locale.CreateLocale(localeId);

            // Customize the name.
            locale.name = "Japanese(日本)";
        }
Beispiel #7
0
 public void CreateTestLocalizationSettings()
 {
     m_Settings        = LocalizationSettingsHelper.CreateEmpty();
     m_LocalesProvider = m_Settings.GetAvailableLocales();
     m_LocalesProvider.AddLocale(Locale.CreateLocale(SystemLanguage.Arabic));
     m_LocalesProvider.AddLocale(Locale.CreateLocale(SystemLanguage.English));
     m_LocalesProvider.AddLocale(Locale.CreateLocale(SystemLanguage.French));
     m_LocalesProvider.AddLocale(Locale.CreateLocale(SystemLanguage.German));
     m_LocalesProvider.AddLocale(Locale.CreateLocale(SystemLanguage.Japanese));
 }
Beispiel #8
0
 protected static List <Locale> GenerateSampleLocales()
 {
     return(new List <Locale>()
     {
         Locale.CreateLocale(SystemLanguage.English),
         Locale.CreateLocale(SystemLanguage.French),
         Locale.CreateLocale(SystemLanguage.Arabic),
         Locale.CreateLocale(SystemLanguage.Japanese),
         Locale.CreateLocale(SystemLanguage.Chinese)
     });
 }
Beispiel #9
0
    private void Start()
    {
        CMInputCallbackInstaller.PersistentObject(transform);
        LocalizationSettings.SelectedLocale = Locale.CreateLocale(Settings.Instance.Language);

        UpdateDSPBufferSize();
        AudioListener.volume = Settings.Instance.Volume;

        centerDisplay.host = this;
        bottomDisplay.host = this;
    }
Beispiel #10
0
        public void ExpectedFormatterIsUsed(string code, bool useCustom, string formatCode, string expectedOutput)
        {
            var locale = Locale.CreateLocale(code);

            locale.CustomFormatterCode = formatCode;
            locale.UseCustomFormatter  = useCustom;

            var formattedText = string.Format(locale.Formatter, "{0:C} {1:N} {2}", 123.45f, 1234567.345, new DateTime(2020, 12, 29));

            Assert.AreEqual(expectedOutput, formattedText);
            Object.DestroyImmediate(locale);
        }
        void Start()
        {
            // Create a locale to represent English.
            var localeId = new LocaleIdentifier(SystemLanguage.English);
            var locale   = Locale.CreateLocale(localeId);

            Debug.Log("English locale: " + locale);

            // Create a regional locale to represent English UK.
            var regionalLocaleId = new LocaleIdentifier("en-GB");
            var regionalLocale   = Locale.CreateLocale(regionalLocaleId);

            Debug.Log("English(en-GB) locale: " + regionalLocale);
        }
        static void CreateCustomLocale()
        {
            // Create a locale to represent a Custom language
            var locale = Locale.CreateLocale(new LocaleIdentifier("my language code"));

            // Customize the name.
            locale.name = "My Custom Language";

            var path = EditorUtility.SaveFilePanelInProject("Save Custom Locale Asset", locale.name, "asset", null);

            if (!string.IsNullOrEmpty(path))
            {
                AssetDatabase.CreateAsset(locale, path);
            }
        }
        static void CreateJapanese()
        {
            // Create a locale to represent Japanese.
            var locale = Locale.CreateLocale(SystemLanguage.Japanese);

            // Customize the name.
            locale.name = "Japanese(日本)";

            var path = EditorUtility.SaveFilePanelInProject("Save Japanese Locale Asset", locale.name, "asset", null);

            if (!string.IsNullOrEmpty(path))
            {
                AssetDatabase.CreateAsset(locale, path);
            }
        }
        void Start()
        {
            // Create a locale to represent English.
            var localeId = new LocaleIdentifier(SystemLanguage.English);
            var locale   = Locale.CreateLocale(localeId);

            // Create a regional locale to represent English UK.
            var regionalLocaleId = new LocaleIdentifier("en-GB");
            var regionalLocale   = Locale.CreateLocale(regionalLocaleId);

            // Fallback from English(UK) to the non-regional English version.
            regionalLocale.FallbackLocale = locale;

            Debug.Log("English(en-GB) will fallback to " + regionalLocale.FallbackLocale);
        }
        public void Setup()
        {
            m_Instance         = ScriptableObject.CreateInstance <Fixture>();
            m_ScriptableObject = new SerializedObject(m_Instance);
            m_Property         = m_ScriptableObject.FindProperty("provider");
            Assert.That(m_ScriptableObject, Is.Not.Null);
            Assert.That(m_Property, Is.Not.Null);

            m_FakeLocaleProvider = new FakeLocaleProvider();
            LocalizationEditorSettings.Instance = m_FakeLocaleProvider;
            LocalizationEditorSettings.AddLocale(Locale.CreateLocale(SystemLanguage.English));
            LocalizationEditorSettings.AddLocale(Locale.CreateLocale(SystemLanguage.French));
            LocalizationEditorSettings.AddLocale(Locale.CreateLocale(SystemLanguage.Korean));

            m_PropertyDrawer = new LocalesProviderPropertyDrawer();
        }
        public void CreateTestLocalizationSettings()
        {
            m_Settings = LocalizationSettings.CreateDefault();
            LocalizationSettings.Instance = m_Settings;

            var simpleLocalesProvider = ScriptableObject.CreateInstance <SimpleLocalesProvider>();

            m_Settings.SetAvailableLocales(simpleLocalesProvider);
            var sl = LocalizationSettings.AvailableLocales;

            sl.AddLocale(Locale.CreateLocale(new LocaleIdentifier(SystemLanguage.Arabic)));
            sl.AddLocale(Locale.CreateLocale(new LocaleIdentifier(SystemLanguage.English)));
            sl.AddLocale(Locale.CreateLocale(new LocaleIdentifier(SystemLanguage.French)));
            sl.AddLocale(Locale.CreateLocale(new LocaleIdentifier(SystemLanguage.German)));
            sl.AddLocale(Locale.CreateLocale(new LocaleIdentifier(SystemLanguage.Japanese)));
        }
        public void Init()
        {
            m_OriginalSettings            = LocalizationSettings.Instance;
            m_TestSettings                = LocalizationSettingsHelper.CreateEmpty();
            LocalizationSettings.Instance = m_TestSettings;

            // Add the test locales
            var localeProvider = m_TestSettings.GetAvailableLocales();

            testLanguages.ForEach(o => localeProvider.AddLocale(Locale.CreateLocale(o)));

            PlayerPrefs.DeleteKey(k_PlayerPrefKey);
            m_PlayerPrefLocaleSelector = new PlayerPrefLocaleSelector {
                PlayerPreferenceKey = k_PlayerPrefKey
            };
            m_TestSettings.GetStartupLocaleSelectors().Add(m_PlayerPrefLocaleSelector);
        }
        void Start()
        {
            // Create our localization settings
            var localizationSettings = LocalizationSettings.CreateDefault();

            // Add the locales we support
            var supportedLocales = localizationSettings.GetAvailableLocales();

            supportedLocales.AddLocale(Locale.CreateLocale(new LocaleIdentifier(SystemLanguage.Arabic)));
            supportedLocales.AddLocale(Locale.CreateLocale(new LocaleIdentifier(SystemLanguage.English)));
            supportedLocales.AddLocale(Locale.CreateLocale(new LocaleIdentifier(SystemLanguage.French)));
            supportedLocales.AddLocale(Locale.CreateLocale(new LocaleIdentifier(SystemLanguage.German)));
            supportedLocales.AddLocale(Locale.CreateLocale(new LocaleIdentifier(SystemLanguage.Japanese)));

            // Set English to be our default
            LocalizationSettings.Instance = localizationSettings;
        }
Beispiel #19
0
        public void ProjectLocalesIsUpdatedWhenRemoveLocaleIsUndone()
        {
            const string localeAssetPath = "Assets/HebrewRemove.asset";
            var          locale          = Locale.CreateLocale(SystemLanguage.Hebrew);

            AssetDatabase.CreateAsset(locale, localeAssetPath);
            LocalizationEditorSettings.AddLocale(locale, false);
            Assert.That(LocalizationEditorSettings.GetLocales(), Does.Contain(locale), "Expected new locale asset to be added to Project Locales.");

            LocalizationEditorSettings.RemoveLocale(locale, true);
            Assert.That(LocalizationEditorSettings.GetLocales(), Does.Not.Contains(locale), "Expected locale to not be in project locales after calling RemoveLocale.");

            Undo.PerformUndo();
            Assert.That(LocalizationEditorSettings.GetLocales(), Does.Contain(locale), "Expected locale asset to be in project locale after calling Undo.");

            AssetDatabase.DeleteAsset(localeAssetPath);
        }
Beispiel #20
0
        public void Setup()
        {
            LocalizationSettingsHelper.SaveCurrentSettings();

            LocalizationSettings.Instance = ScriptableObject.CreateInstance <LocalizationSettings>();

            var localeProvider = new TestLocaleProvider();

            m_Selected = Locale.CreateLocale("en");
            localeProvider.AddLocale(m_Selected);
            LocalizationSettings.Instance.SetAvailableLocales(localeProvider);

            m_FixtureStringDatabase             = new FixtureStringDatabase();
            LocalizationSettings.StringDatabase = m_FixtureStringDatabase;

            m_FixtureStringDatabase.NoTranslationFoundMessage = "No translation found for '{key}'";
            m_GameObject          = new GameObject(nameof(ChangingLocalizedStringUpdatesValues));
            m_LocalizeStringEvent = m_GameObject.AddComponent <LocalizeStringEvent>();

            // Setup with a default value so we do not start with an empty StringReference.
            m_LocalizeStringEvent.StringReference.SetReference(kDefaultTableCollectionName, kDefaultEntryName);
            ClearLastGetTableEntryValues();
        }
Beispiel #21
0
 public void Setup()
 {
     m_Locale = Locale.CreateLocale("my locale");
     AssetDatabase.CreateAsset(m_Locale, kPath);
 }