void Awake() { GlobalWindowManager windowManager = FindObjectOfType <GlobalWindowManager>(); if (windowManager == null) { throw new NotFoundException("Not found the GlobalWindowManager."); } context = Context.GetApplicationContext(); IServiceContainer container = context.GetContainer(); /* Initialize the data binding service */ BindingServiceBundle bundle = new BindingServiceBundle(context.GetContainer()); bundle.Start(); /* Initialize the ui view locator and register UIViewLocator */ container.Register <IUIViewLocator>(new ResourcesViewLocator()); /* Initialize the localization service */ // CultureInfo cultureInfo = Locale.GetCultureInfoByLanguage (SystemLanguage.English); CultureInfo cultureInfo = Locale.GetCultureInfo(); Localization.Current = Localization.Create(new ResourcesDataProvider("LocalizationExamples", new XmlDocumentParser()), cultureInfo); /* register Localization */ container.Register <Localization>(Localization.Current); /* register AccountRepository */ IAccountRepository accountRepository = new AccountRepository(); container.Register <IAccountService>(new AccountService(accountRepository)); }
public void Locale_GetCultureInfoTest(string locale, string expectedName, string expectedEnglishName) { var culture = Locale.GetCultureInfo(locale); Assert.That(culture.Name, Is.EqualTo(expectedName)); Assert.That(culture.EnglishName, Is.EqualTo(expectedEnglishName)); }
protected override void Awake() { ApplicationContext context = Context.GetApplicationContext(); BindingServiceBundle bindingService = new BindingServiceBundle(context.GetContainer()); bindingService.Start(); /* Initialize the ui view locator and register UIViewLocator */ //获得上下文中的服务容器 IServiceContainer container = context.GetContainer(); //初始化IUIViewLocator,并注册到容器 container.Register <IUIViewLocator>(new DefaultUIViewLocator()); //初始化本地化服务,并注册到容器中 CultureInfo cultureInfo = Locale.GetCultureInfo(); var localization = Localization.Current; localization.CultureInfo = cultureInfo; localization.AddDataProvider(new DefaultDataProvider("LocalizationTutorials", new XmlDocumentParser())); container.Register(localization); /* Initialize the dialog service */ IDialogService dialogService = new DefaultDialogService(); container.Register <IDialogService>(dialogService); }
void Awake() { GlobalWindowManager windowManager = FindObjectOfType <GlobalWindowManager>(); if (windowManager == null) { throw new NotFoundException("Not found the GlobalWindowManager."); } context = Context.GetApplicationContext(); IServiceContainer container = context.GetContainer(); /* Initialize the data binding service */ LuaBindingServiceBundle bundle = new LuaBindingServiceBundle(context.GetContainer()); bundle.Start(); /* Initialize the ui view locator and register UIViewLocator */ container.Register <IUIViewLocator>(new DefaultUIViewLocator()); /* Initialize the localization service */ //CultureInfo cultureInfo = Locale.GetCultureInfoByLanguage (SystemLanguage.English); CultureInfo cultureInfo = Locale.GetCultureInfo(); var localization = Localization.Current; localization.CultureInfo = cultureInfo; localization.AddDataProvider(new DefaultDataProvider("LuaLocalizations", new XmlDocumentParser())); /* register Localization */ container.Register <Localization>(Localization.Current); var luaEnv = LuaEnvironment.LuaEnv; #if UNITY_EDITOR foreach (string dir in Directory.GetDirectories(Application.dataPath, "LuaScripts", SearchOption.AllDirectories)) { luaEnv.AddLoader(new FileLoader(dir, ".lua")); luaEnv.AddLoader(new FileLoader(dir, ".lua.txt")); } #else /* Pre-compiled and encrypted */ //var decryptor = new RijndaelCryptograph(128,Encoding.ASCII.GetBytes("E4YZgiGQ0aqe5LEJ"), Encoding.ASCII.GetBytes("5Hh2390dQlVh0AqC")); //luaEnv.AddLoader( new DecodableLoader(new FileLoader(Application.streamingAssetsPath + "/LuaScripts/", ".bytes"), decryptor)); //luaEnv.AddLoader( new DecodableLoader(new FileLoader(Application.persistentDataPath + "/LuaScripts/", ".bytes"), decryptor)); /* Lua source code */ luaEnv.AddLoader(new FileLoader(Application.streamingAssetsPath + "/LuaScripts/", ".bytes")); luaEnv.AddLoader(new FileLoader(Application.persistentDataPath + "/LuaScripts/", ".bytes")); #endif InitLuaEnv(); if (onAwake != null) { onAwake(this); } }
protected override void Awake() { ApplicationContext context = Context.GetApplicationContext(); BindingServiceBundle bindingService = new BindingServiceBundle(context.GetContainer()); bindingService.Start(); CultureInfo cultureInfo = Locale.GetCultureInfo(); Localization.Current = Localization.Create(new DefaultDataProvider("LocalizationTutorials", new XmlDocumentParser()), cultureInfo); }
void Awake() { GlobalWindowManager windowManager = FindObjectOfType <GlobalWindowManager>(); if (windowManager == null) { throw new NotFoundException("Not found the GlobalWindowManager."); } context = Context.GetApplicationContext(); IServiceContainer container = context.GetContainer(); /* Initialize the data binding service */ BindingServiceBundle bundle = new BindingServiceBundle(context.GetContainer()); bundle.Start(); /* Initialize the ui view locator and register UIViewLocator */ container.Register <IUIViewLocator>(new ResourcesViewLocator()); /* Initialize the localization service */ //CultureInfo cultureInfo = Locale.GetCultureInfoByLanguage (SystemLanguage.English); CultureInfo cultureInfo = Locale.GetCultureInfo(); var localization = Localization.Current; localization.CultureInfo = cultureInfo; localization.AddDataProvider(new ResourcesDataProvider("LocalizationExamples", new XmlDocumentParser())); /* register Localization */ container.Register <Localization>(localization); /* register AccountRepository */ IAccountRepository accountRepository = new AccountRepository(); container.Register <IAccountService>(new AccountService(accountRepository)); /* Enable window state broadcast */ GlobalSetting.enableWindowStateBroadcast = true; /* * Use the CanvasGroup.blocksRaycasts instead of the CanvasGroup.interactable * to control the interactivity of the view */ GlobalSetting.useBlocksRaycastsInsteadOfInteractable = true; /* Subscribe to window state change events */ subscription = Window.Messenger.Subscribe <WindowStateEventArgs>(e => { Debug.LogFormat("The window[{0}] state changed from {1} to {2}", e.Window.Name, e.OldState, e.State); }); }
protected override void Awake() { ApplicationContext context = Context.GetApplicationContext(); BindingServiceBundle bindingService = new BindingServiceBundle(context.GetContainer()); bindingService.Start(); /* Initialize the ui view locator and register UIViewLocator */ IServiceContainer container = context.GetContainer(); container.Register <IUIViewLocator>(new DefaultUIViewLocator()); CultureInfo cultureInfo = Locale.GetCultureInfo(); Localization.Current = Localization.Create(new DefaultDataProvider("LocalizationTutorials", new XmlDocumentParser()), cultureInfo); }
protected override void Awake() { //获得全局的应用上下文 ApplicationContext context = Context.GetApplicationContext(); //context.GetContainer()获得上下文中的服务容器 //初始化数据绑定服务,这是一组服务,通过ServiceBundle来初始化并注册到服务容器中 BindingServiceBundle bindingService = new BindingServiceBundle(context.GetContainer()); bindingService.Start(); //初始化本地化服务 CultureInfo cultureInfo = Locale.GetCultureInfo(); var localization = Localization.Current; localization.CultureInfo = cultureInfo; localization.AddDataProvider(new DefaultDataProvider("LocalizationTutorials", new XmlDocumentParser())); }
protected override void Awake() { //获得应用上下文 ApplicationContext context = Context.GetApplicationContext(); //启动数据绑定服务 BindingServiceBundle bindingService = new BindingServiceBundle(context.GetContainer()); bindingService.Start(); //初始化本地化服务 //CultureInfo cultureInfo = Locale.GetCultureInfo(); //var provider = new DefaultDataProvider("LocalizationTutorials", new XmlDocumentParser()); //Localization.Current = Localization.Create(provider, cultureInfo); CultureInfo cultureInfo = Locale.GetCultureInfo(); localization = Localization.Current; localization.CultureInfo = cultureInfo; localization.AddDataProvider(new DefaultDataProvider("LocalizationTutorials", new XmlDocumentParser())); }
protected virtual void OnEnable() { var sourceProperty = serializedObject.FindProperty("Source"); var entriesProperty = sourceProperty.FindPropertyRelative("entries"); var languagesProperty = sourceProperty.FindPropertyRelative("languages"); this.source = (target as LocalizationSourceBehaviour).Source; this.languages = source.Languages; if (this.languages.Count <= 0) { CultureInfo cultureInfo = Locale.GetCultureInfo(); this.languages.Add(cultureInfo.Name); } entryList = new ReorderableList(entriesProperty.serializedObject, entriesProperty, true, true, true, true); entryList.elementHeight = 22; entryList.onAddCallback = OnAddEntry; entryList.onRemoveCallback = OnRemoveEntry; entryList.drawHeaderCallback = DrawEntryListHeader; entryList.drawElementCallback = DrawEntryListElement; entryList.elementHeightCallback = EntryListElementHeight; entryList.drawElementBackgroundCallback = DrawElementBackground; languageList = new ReorderableList(languagesProperty.serializedObject, languagesProperty, true, true, true, true); languageList.elementHeight = 22; languageList.onAddCallback = OnAddLanguage; languageList.onRemoveCallback = OnRemoveLanguage; languageList.drawHeaderCallback = DrawLanguageListHeader; languageList.drawElementCallback = DrawLanguageListElement; languageList.drawElementBackgroundCallback = DrawElementBackground; languageList.onSelectCallback = list => { this.selectedLanguageIndex = list.index; }; languageList.onReorderCallback = list => { int oldIndex = this.selectedLanguageIndex; int newIndex = list.index; OnMove(oldIndex, newIndex); this.selectedLanguageIndex = newIndex; }; }
public void Locale_GetCultureInfoTest_Exceptions() { Assert.That(() => Locale.GetCultureInfo(null), Throws.ArgumentNullException); }
static void Generate() { var selections = Selection.GetFiltered(typeof(TextAsset), SelectionMode.DeepAssets); if (selections == null || selections.Length <= 0) { return; } var dir = EditorPrefs.GetString(OUTPUT_DIR_KEY, DEFAULT_OUTPUT_DIR); var className = EditorPrefs.GetString(CLASS_NAME_KEY, DEFAULT_CLASS_NAME); string location = EditorUtility.SaveFilePanel("Generate Code", dir, className, "cs"); if (string.IsNullOrEmpty(location)) { return; } dir = GetRelativeDirectory(location); className = GetClassName(location); EditorPrefs.SetString(OUTPUT_DIR_KEY, dir); EditorPrefs.SetString(CLASS_NAME_KEY, className); CodeGenerator generator = new CodeGenerator(); XmlDocumentParser parser = new XmlDocumentParser(); Dictionary <string, object> data = new Dictionary <string, object> (); foreach (var s in selections) { try { string path = AssetDatabase.GetAssetPath(s); if (!path.ToLower().EndsWith(EXTENSION)) { continue; } var dict = parser.Parse(new MemoryStream((s as TextAsset).bytes), Locale.GetCultureInfo()); foreach (KeyValuePair <string, object> kv in dict) { data [kv.Key] = kv.Value; } } catch (Exception) { } } if (data.Count <= 0) { return; } var code = generator.Generate(className, data); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } File.WriteAllText(location, code); AssetDatabase.Refresh(); }