Esempio n. 1
0
    private static void ImportFileToDefaultGroupAndSourceLanguageDB()     //does not import it to a group
    {
        TextAsset ta = Selection.activeObject as TextAsset;

        if (ta == null)
        {
            Debug.LogError("Selected item is not a text asset");
            return;
        }
        string[] toSplit = new string[] { "\n", "\r\n" };
        string[] newKeys = ta.text.Split(toSplit, StringSplitOptions.RemoveEmptyEntries);

        var dic = new Dictionary <string, string>();

        foreach (string key in newKeys)
        {
            if (!dic.ContainsKey(key))
            {
                dic.Add(key, key);
            }
        }

        var translationConfig = ResourceLoadFacade.LoadConfigGroup("");
        var currentSet        = GameTranslationGetter.GetTranslaitonSetFromLanguageCode(translationConfig.sourceLanguage.code);

        currentSet.mergeInSet("", dic);

        /*
         * var languageCodeList = new List<string> { translationConfig.sourceLanguage.code };
         * translationConfig.destinationLanguages.ForEach((TransfluentLanguage lang) => { languageCodeList.Add(lang.code); });
         *
         * DownloadAllGameTranslations.uploadTranslationSet(languageCodeList, translationConfig.translation_set_group);
         */
    }
Esempio n. 2
0
        public static void uploadTranslationSet(List <string> languageCodes, string groupid)
        {
            TransfluentEditorWindowMediator mediator = getAuthenticatedMediator();

            if (mediator == null)
            {
                return;
            }

            foreach (string languageCode in languageCodes)
            {
                try
                {
                    GameTranslationSet set = GameTranslationGetter.GetTranslaitonSetFromLanguageCode(languageCode);
                    GameTranslationSet.GroupOfTranslations groupData = set.getGroup(groupid);
                    TransfluentLanguage lang = ResourceLoadFacade.getLanguageList().getLangaugeByCode(languageCode);
                    if (groupData.translations.Count > 0)
                    {
                        mediator.SaveGroupToServer(groupData, lang);
                    }
                }
                catch
                {
                }
            }
        }
Esempio n. 3
0
    public static TranslationConfigurationSO getOrCreateGameTranslationConfig(string groupid)
    {
        string fileName = ResourceLoadFacade.TranslationConfigurationSOFileNameFromGroupID(groupid);
        TranslationConfigurationSO config =
            ResourceLoadFacade.LoadConfigGroup(groupid) ??
            ResourceCreator.CreateSO <TranslationConfigurationSO>(fileName);

        config.translation_set_group = groupid;
        return(config);
    }
    public static void ImportAllNGUILocalizations()
    {
        LanguageList list             = ResourceLoadFacade.getLanguageList();
        string       nguiLocalization = ResourceLoadFacade.LoadResource <TextAsset>("Localization").text;
        var          importer         = new NGUILocalizationCSVImporter(nguiLocalization);
        Dictionary <string, Dictionary <string, string> > map = importer.getMapOfLanguagesToKeyValueTranslations();

        foreach (var languageCommonNameToKeyValues in map)
        {
            string commonName = languageCommonNameToKeyValues.Key;
            Dictionary <string, string> keyValues = languageCommonNameToKeyValues.Value;
            string languageCode = takeLanguageNameAndTurnItIntoAKnownLanguageCode(commonName);

            TransfluentLanguage language = list.getLangaugeByCode(languageCode);
            saveSet(language, keyValues, "NGUI");             //groupid -- NGUI
        }
    }
        public LanguageList getLanguageList()
        {
            allLanguagesSupported = ResourceLoadFacade.getLanguageList();
            if (allLanguagesSupported == null)
            {
                requestAllLanguagesInEditorSynchronous();
                if (allLanguagesSupported != null)
                {
                    //allLanguagesSupported,
                    var languageListSO = ResourceCreator.CreateSO <LanguageListSO>("LanguageList");
                    languageListSO.list = allLanguagesSupported;
                    //do I need to set this dirty?
                }
            }

            return(allLanguagesSupported);
        }
        public void addToDB(string key, string value)
        {
            string currentGroup = _translationDB.groupBeingShown;
            TranslationConfigurationSO  config = ResourceLoadFacade.LoadConfigGroup(_translationDB.groupBeingShown);
            Dictionary <string, string> translationDictionary = _translationDB.allKnownTranslations;
            GameTranslationSet          gameTranslationSet    =
                GameTranslationGetter.GetTranslaitonSetFromLanguageCode(config.sourceLanguage.code);

            bool exists = translationDictionary.ContainsKey(key);

            if (!exists)
            {
                translationDictionary.Add(key, key);
            }

            gameTranslationSet.mergeInSet(currentGroup, translationDictionary);
            //_translationDB.allKnownTranslations.Add(key,value);
        }
    public static string getLocalizationPath()
    {
        string localizationPath =
            AssetDatabase.GetAssetPath(ResourceLoadFacade.LoadResource <TextAsset>("Localization"));
        string projectBasePath =
            Path.GetFullPath(Application.dataPath + Path.DirectorySeparatorChar + ".." + Path.DirectorySeparatorChar);

        if (string.IsNullOrEmpty(localizationPath))
        {
            localizationPath = "Assets/Resources/Localization.txt";
            if (!Directory.Exists("Assets/Resources"))
            {
                AssetDatabase.CreateFolder("Assets", "Resources");
            }
            File.WriteAllText(projectBasePath + localizationPath, "");

            //TextAsset ta = new TextAsset();
            //AssetDatabase.CreateAsset(ta, localizationPath);
            AssetDatabase.ImportAsset(localizationPath, ImportAssetOptions.ForceSynchronousImport);
        }

        return(projectBasePath + localizationPath);
    }
    public void testLanguageListGetterWithNoList()
    {
        //LanguageList list = ResourceLoadAdapter.getLanguageList();
        //Assets/Transfluent/Resources/LanguageList.asset
        string languageListPath = "Assets/Transfluent/Resources/LanguageList.asset";

        AssetDatabase.DeleteAsset(languageListPath);
        IWebService            service = new SyncronousEditorWebRequest();
        var                    request = new RequestAllLanguages();
        WebServiceReturnStatus status  = service.request(request);
        LanguageList           list    = request.Parse(status.text);

        Assert.NotNull(list);
        Assert.NotNull(list.languages);
        Assert.Greater(list.languages.Count, 0);

        var so = ResourceCreator.CreateSO <LanguageListSO>("LanguageList");

        so.list = list;
        EditorUtility.SetDirty(so);

        LanguageList newList = ResourceLoadFacade.getLanguageList();

        //NOTE: THIS IS THE RUNTIME VERSION... not the editor time version

        AssetDatabase.SaveAssets();
        //manual load

        var fromDisk = AssetDatabase.LoadAssetAtPath(languageListPath, typeof(LanguageListSO)) as LanguageListSO;

        Assert.NotNull(fromDisk);
        Assert.NotNull(fromDisk.list);
        Assert.NotNull(fromDisk.list.languages);
        Assert.Greater(fromDisk.list.languages.Count, 0);
        Debug.Log("newlist:" + JsonWriter.Serialize(newList));
    }
Esempio n. 9
0
 // Use this for initialization
 private void Start()
 {
     config = ResourceLoadFacade.LoadConfigGroup("");
     populateKnownTranslationsInGroup();
     TranslationUtility.changeStaticInstanceConfig("xx-xx");
 }