Beispiel #1
0
        private void InitLocalization()
        {
            CultureInfo currentCultureInfo = localizeService.GetCurrentCultureInfo();

            AppResources.Culture = currentCultureInfo;
            localizeService.SetLocale(currentCultureInfo);
        }
Beispiel #2
0
        private void SetCulture()
        {
            Debug.WriteLine("====== resource debug info =========");
            var assembly = typeof(App).GetTypeInfo().Assembly;

            foreach (var res in assembly.GetManifestResourceNames())
            {
                Debug.WriteLine("found resource: " + res);
            }
            Debug.WriteLine("====================================");

            // This lookup NOT required for Windows platforms - the Culture will be automatically set
            if (Device.OS == TargetPlatform.iOS || Device.OS == TargetPlatform.Android)
            {
                var ci = _localizeService.GetCurrentCultureInfo();
                AppResources.Culture = ci;
                _localizeService.SetLocale(ci);
            }
        }
Beispiel #3
0
        private void SetCulture()
        {
            Debug.WriteLine("====== resource debug info =========");
            var assembly = typeof(App).GetTypeInfo().Assembly;

            foreach (var res in assembly.GetManifestResourceNames())
            {
                Debug.WriteLine("found resource: " + res);
            }
            Debug.WriteLine("====================================");

            // This lookup NOT required for Windows platforms - the Culture will be automatically set
            if (Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Android)
            {
                var ci = _localizeService.GetCurrentCultureInfo();
                AppResources.Culture = ci;
                _localizeService.SetLocale(ci);
            }

            // Calendars are removed by linker. ref https://bugzilla.xamarin.com/show_bug.cgi?id=59077
            new System.Globalization.ThaiBuddhistCalendar();
            new System.Globalization.HijriCalendar();
            new System.Globalization.UmAlQuraCalendar();
        }
        public static string Translate(this ILocalizeService localizeService, string str)
        {
            var tranlation = AppResources.ResourceManager.GetString(str, localizeService.GetCurrentCultureInfo());

            return(string.IsNullOrEmpty(tranlation) ? str : tranlation);
        }
Beispiel #5
0
 public TranslateService(ILocalizeService localizeHelper)
 {
     ci = localizeHelper.GetCurrentCultureInfo();
 }