Exemple #1
0
        //TODO: how to encode content so that group ids are handled
        public string SendFileContents(Dictionary <string, string> keys, TransfluentLanguage sourceLanguage, string groupid, string comment)
        {        //<?xml version=""1.0"" encoding=""UTF-8"" ?>
            //<?xml version=""1.0"" encoding=""UTF-8"" ?>
            string headerFormat = @"
<locale>
	<id>{0}</id>
	<code>{1}</code>
	<name>{2}</name>
";
            //ie 148, en-us, "English US"
            string header = string.Format(headerFormat, sourceLanguage.id, sourceLanguage.code, sourceLanguage.name);
            string footer = "</locale>";

            string        textsFormat          = "<texts>{0}</texts>";
            string        individualTextFormat = @"<text>
			<textId>{0}</textId>
			<textString>{1}</textString>
		</text>
";
            StringBuilder sb = new StringBuilder();

            foreach (KeyValuePair <string, string> kvp in keys)
            {
                sb.AppendFormat(individualTextFormat, kvp.Key, kvp.Value);
            }

            string texts = string.Format(textsFormat, sb.ToString());

            string contentToSend = string.Format("{0}\n{1}\n{2}", header, texts, footer);

            return(contentToSend);
        }
Exemple #2
0
        public int numberOfMissingTranslationsBetweenLanguages(TransfluentLanguage sourceLang, TransfluentLanguage destLang, string groupid)
        {
            var sourceSet = GameTranslationGetter.GetTranslaitonSetFromLanguageCode(sourceLang.code);
            var destSet   = GameTranslationGetter.GetTranslaitonSetFromLanguageCode(destLang.code);

            var sourceGroup = sourceSet.getGroup(groupid);
            var sourceKeys  = new List <string>(sourceGroup.getDictionaryCopy().Keys);
            var destKeys    = new List <string>();

            if (destSet != null)
            {
                destKeys.AddRange(destSet.getGroup(groupid).getDictionaryCopy().Keys);
            }
            return(numberOfMissingKeysFromLists(sourceKeys, destKeys));
        }
Exemple #3
0
        //public static event Action OnLanguageChanged;

        public static ITranslationUtilityInstance createNewInstance(string destinationLanguageCode = "", string group = "")
        {
            if (_LanguageList == null)
            {
                _LanguageList = ResourceLoadFacade.getLanguageList();
            }

            if (_LanguageList == null)
            {
                Debug.LogError("Could not load new language list");
                return(null);
            }
            bool enableCapture = false;

#if UNITY_EDITOR
            if (Application.isEditor)
            {
                enableCapture = getCaptureMode();
            }
#endif //UNTIY_EDITOR

            TransfluentLanguage dest = _LanguageList.getLangaugeByCode(destinationLanguageCode);
            if (dest == null)
            {
                TranslationConfigurationSO defaultConfigInfo = ResourceLoadFacade.LoadConfigGroup(group);
                string newDestinationLanguageCode            = defaultConfigInfo.sourceLanguage.code;

                /*
                 * if (string.IsNullOrEmpty(destinationLanguageCode))
                 * {
                 *      Debug.Log("Using default destination language code, as was given an empty language code");
                 * }
                 * else
                 *      Debug.Log("Could not load destination language code:" + destinationLanguageCode + " so falling back to source game language code:" + destinationLanguageCode);
                 */
                destinationLanguageCode = newDestinationLanguageCode;

                dest = _LanguageList.getLangaugeByCode(destinationLanguageCode);
                //dest = _LanguageList.getLangaugeByCode
            }
            GameTranslationSet          destLangDB = GameTranslationGetter.GetTranslaitonSetFromLanguageCode(destinationLanguageCode);
            Dictionary <string, string> keysInLanguageForGroupSpecified = destLangDB != null
                                ? destLangDB.getGroup(group).getDictionaryCopy()
                                : new Dictionary <string, string>();

#if UNITY_EDITOR
            EditorUtility.SetDirty(destLangDB);
#endif

            var newTranslfuentUtilityInstance = new TranslationUtilityInstance
            {
                allKnownTranslations = keysInLanguageForGroupSpecified,
                destinationLanguage  = dest,
                groupBeingShown      = group,
            };
            if (enableCapture)
            {
                newTranslfuentUtilityInstance = new AutoCaptureTranslationUtiliityInstance()
                {
                    allKnownTranslations = keysInLanguageForGroupSpecified,
                    destinationLanguage  = dest,
                    groupBeingShown      = group,
                    doCapture            = enableCapture,
                    coreTransltionSet    = destLangDB,
                };
            }
            return(newTranslfuentUtilityInstance);
        }