static void OpenMenuChangeLanguage(UIViewController Controller, NSBundle LanguageBundle)
        {
            var Title         = LanguageBundle.LocalizedString("Language", null);
            var Message       = LanguageBundle.LocalizedString("Choose your preferred language", null);
            var LanguageAlert = UIAlertController.Create(Title, Message, UIAlertControllerStyle.ActionSheet);

            LanguageAlert.View.Layer.CornerRadius = 15;
            LanguageAlert.View.TintColor          = Colors.DarkPurple;

            var Subview = LanguageAlert.View.Subviews[0].Subviews[0] as UIView;

            foreach (var V in Subview.Subviews)
            {
                V.BackgroundColor = Colors.Pink;
            }

            var AvailableLanguages = LanguageHelper.ListLanguages;

            foreach (var Value in AvailableLanguages)
            {
                var AlertActionOption = UIAlertAction.Create(Value, UIAlertActionStyle.Default, (obj) => ActionChangeLanguage(obj.Title, Controller));
                LanguageAlert.AddAction(AlertActionOption);
            }

            var AlertActionCancel = UIAlertAction.Create(LanguageBundle.LocalizedString("Cancel", null), UIAlertActionStyle.Cancel, (obj) => LanguageAlert.DismissViewController(true, null));

            LanguageAlert.AddAction(AlertActionCancel);

            if (LanguageAlert.PopoverPresentationController != null)
            {
                LanguageAlert.PopoverPresentationController.BarButtonItem = LanguageButton;
            }

            Controller.PresentViewController(LanguageAlert, true, null);
        }
Exemple #2
0
        public static string GetText(string key)
        {
            string text = m_bundle.LocalizedString(key, key);

            if (text == key && DeviceLanguageCode != "en" && !key.Contains(":"))
            {
                text = m_bundle.LocalizedString(key + ":", key).Replace(":", "");
            }
            return(text);
        }
Exemple #3
0
        public static string GetText(string key)
        {
#pragma warning disable CS0618 // Type or member is obsolete
            string text = m_bundle.LocalizedString(key, key);
            if (text == key && DeviceLanguageCode != "en" && !key.Contains(":"))
            {
                text = m_bundle.LocalizedString(key + ":", key).Replace(":", "");
#pragma warning restore CS0618 // Type or member is obsolete
            }
            return(text);
        }
Exemple #4
0
        public static string GetLocalizedString(string key, string comment)
        {
//			Console.WriteLine(string.Format("Locale: {0} - Language: {1}",
//		         NSLocale.CurrentLocale.LocaleIdentifier,
//		         NSLocale.PreferredLanguages[0]));
            return(localeBundle.LocalizedString(key, comment));
        }
Exemple #5
0
        public void LocalizedString2()
        {
            string s = main.LocalizedString(null, "comment");

            Assert.That(s, Is.Empty, "key");

            s = main.LocalizedString("key", null);
            Assert.That(s, Is.EqualTo("key"), "comment");

            s = main.LocalizedString(null, null);
            Assert.That(s, Is.Empty, "all-null");
        }
Exemple #6
0
        private string GetLocalizedStringOrDefault(string id, NSBundle bundle)
        {
            // From Apple doc :
            // If key is nil and value is nil, returns an empty string.
            // If key is nil and value is non-nil, returns value.
            // If key is not found and value is nil or an empty string, returns key.
            // If key is not found and value is non-nil and not empty, return value.
#pragma warning disable CS0618 // Type or member is obsolete
            var localizedString = bundle.LocalizedString(id, KeyNotFoundValue, null);
#pragma warning restore CS0618 // Type or member is obsolete

            if (localizedString == KeyNotFoundValue)
            {
                return(null);
            }

            return(localizedString);
        }
Exemple #7
0
 public static string GetText(string str)
 {
     return(main.LocalizedString(str, "", ""));
 }
 public string GetString(string stringName)
 {
     return(_bundle.LocalizedString(stringName, null));
 }
Exemple #9
0
        public void LocalizedString2()
        {
#if NET
            string s = main.GetLocalizedString(null, "value");
            Assert.That(s, Is.EqualTo("value"), "key");
#else
            string s = main.LocalizedString(null, "comment");
            Assert.That(s, Is.Empty, "key");
#endif

            s = main.GetLocalizedString("key", null);
            Assert.That(s, Is.EqualTo("key"), "key");

            s = main.GetLocalizedString(null, null);
            Assert.That(s, Is.Empty, "all-null");
        }