public static Binding GetLocaleBinding(string path)
        {
            Binding binding = new Binding()
            {
                Source = (object)BlueStacksUIBinding.Instance
            };
            string str = "";

            if (path != null)
            {
                foreach (char ch in path)
                {
                    str = str + "^" + ch.ToString();
                }
            }
            binding.Path                = new PropertyPath("Instance.LocaleModel.[" + str.ToUpper(CultureInfo.InvariantCulture) + "]", new object[0]);
            binding.Mode                = BindingMode.OneWay;
            binding.FallbackValue       = (object)LocaleStrings.RemoveConstants(path);
            binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            LocaleStrings.AppendLocaleIfDoesntExist(path, LocaleStrings.RemoveConstants(path));
            return(binding);
        }
示例#2
0
        public static string GetLocalizedString(string id, string fallbackValue = "")
        {
            if (id == null)
            {
                return(string.Empty);
            }
            string str = id.Trim();

            try
            {
                if (LocaleStrings.sDictLocalizedString == null)
                {
                    LocaleStrings.InitLocalization((string)null, "Android", false);
                }
                str = !LocaleStrings.sDictLocalizedString.ContainsKey(id.ToUpper(CultureInfo.InvariantCulture)) ? (!string.IsNullOrEmpty(fallbackValue) ? fallbackValue : LocaleStrings.RemoveConstants(id)) : LocaleStrings.sDictLocalizedString[id.ToUpper(CultureInfo.InvariantCulture)];
            }
            catch
            {
                Logger.Warning("Localized string not available for: {0}", (object)id);
            }
            return(str);
        }