Ejemplo n.º 1
0
        public void LocalizeManualStringsXml(string unlocalizedPath, string localizedPath)
        {
            var parser = new AndroidResourceParser ();
            parser.Add (unlocalizedPath);

            using (var xml = new XmlTextWriter (localizedPath, Encoding.UTF8)) {
                WriteDocument (xml, parent => {
                    foreach (LocalizedString @string in parser.Parse ()) {
                        var found_localization = false;

                        foreach (var localized_string in Strings) {
                            if (localized_string.UntranslatedSingularValue == @string.UntranslatedSingularValue) {
                                var translated = String.IsNullOrWhiteSpace (@localized_string.TranslatedValues [0])
                                    ? localized_string.UntranslatedSingularValue
                                    : localized_string.TranslatedValues [0];

                                WriteString (parent, @string.Name, translated, formatted: true);

                                found_localization = true;
                                break;
                            }
                        }

                        if (!found_localization) {
                            WriteString (parent, @string.Name, @string.UntranslatedSingularValue, formatted: true);
                        }
                    }
                });
            }
        }
Ejemplo n.º 2
0
        public void LocalizeManualStringsXml(string unlocalizedPath, string localizedPath)
        {
            var parser = new AndroidResourceParser ();
            parser.Add (unlocalizedPath);

            using (var xml = new XmlTextWriter (localizedPath, Encoding.UTF8)) {
                WriteDocument (xml, parent => {
                    foreach (var @string in parser.Parse ()) {
                        foreach (var localized_string in Strings) {
                            if (localized_string.UntranslatedSingularValue == @string.UntranslatedSingularValue) {
                                WriteString (parent, @string.Name, @localized_string.TranslatedValues[0]);
                            }
                        }
                    }
                });
            }
        }