Exemplo n.º 1
0
        /// <summary>Renames the localized file from resources.</summary>
        public static void RenameFileFromResources(string key, string newKey, SmartCultureInfo cultureInfo)
        {
            string languageFolderPath   = null;
            LocalizedObjectType keyType = LocalizedObject.GetLocalizedObjectType(key);
            string cleanKey             = LocalizedObject.GetCleanKey(key);
            string cleanNewKey          = LocalizedObject.GetCleanKey(newKey);

            switch (keyType)
            {
            case LocalizedObjectType.GAME_OBJECT:
                languageFolderPath = LocalizationWorkspace.LanguagePrefabsFolderPathRelative(cultureInfo.languageCode) + "/" + cleanKey + LocalizationWorkspace.prefabFileEnding;
                break;

            case LocalizedObjectType.AUDIO:
                languageFolderPath = LocalizationWorkspace.LanguageAudioFolderPathRelative(cultureInfo.languageCode);
                break;

            case LocalizedObjectType.TEXTURE:
                languageFolderPath = LocalizationWorkspace.LanguageTexturesFolderPathRelative(cultureInfo.languageCode);
                break;

            case LocalizedObjectType.TEXT_ASSET:
                languageFolderPath = LocalizationWorkspace.LanguageTextAssetsFolderPathRelative(cultureInfo.languageCode);
                break;

            case LocalizedObjectType.FONT:
                languageFolderPath = LocalizationWorkspace.LanguageFontsFolderPathRelative(cultureInfo.languageCode);
                break;
            }

            if (keyType != LocalizedObjectType.GAME_OBJECT)
            {
                string fileExtension = FileUtility.GetFileExtension(cleanKey, languageFolderPath);
                languageFolderPath += "/" + cleanKey + fileExtension;
            }

            if (FileUtility.Exists(Application.dataPath + languageFolderPath))
            {
                AssetDatabase.RenameAsset("Assets" + languageFolderPath, cleanNewKey);
            }

            AssetDatabase.Refresh();
        }
        static string GetValueFolderPath(string currentDirectory, SmartCultureInfo cultureInfo)
        {
            if (cultureInfo.languageCode.Contains("-"))
            {
                var    words = cultureInfo.languageCode.Split('-');
                string path  = currentDirectory + "/" + ValuesFolderName + "-";
                if (words.Length > 0)
                {
                    path += words[0];
                }
                if (words.Length > 1)
                {
                    path += "-r" + words[1];
                }

                return(path);
            }

            return(currentDirectory + "/" + ValuesFolderName + "-" + cultureInfo.languageCode);
        }
    void Start()
    {
        thisLanguageManager = LanguageManager.Instance;

        SmartCultureInfo systemLanguage = thisLanguageManager.GetDeviceCultureIfSupported();

        if (thisLanguageManager.IsCultureSupported(systemLanguage))
        {
            thisLanguageManager.ChangeLanguage(systemLanguage);
            //thisLanguageManager.ChangeLanguage("ko-KR");
        }
        thisLanguageManager = LanguageManager.Instance;



        Line1.text = thisLanguageManager.GetTextValue("Upgrades.NotEnoughDiamonds");
        Line2.text = thisLanguageManager.GetTextValue("Upgrades.DoYouWant");
        Yes.text   = thisLanguageManager.GetTextValue("Menu.Yes");
        No.text    = thisLanguageManager.GetTextValue("Menu.No");
    }
        /// <summary> Deletes the localized file from resources.</summary>
        public static void DeleteFileFromResources(string key, SmartCultureInfo cultureInfo)
        {
            string languageFolderPath   = string.Empty;
            string cleanKey             = LocalizedObject.GetCleanKey(key);
            LocalizedObjectType keyType = LocalizedObject.GetLocalizedObjectType(key);

            switch (keyType)
            {
            case LocalizedObjectType.GameObject:
                languageFolderPath = LocalizationWorkspace.LanguagePrefabsFolderPathRelative(cultureInfo.languageCode) + "/" + cleanKey + LocalizationWorkspace.prefabFileEnding;
                break;

            case LocalizedObjectType.Audio:
                languageFolderPath = LocalizationWorkspace.LanguageAudioFolderPathRelative(cultureInfo.languageCode);
                break;

            case LocalizedObjectType.Texture:
                languageFolderPath = LocalizationWorkspace.LanguageTexturesFolderPathRelative(cultureInfo.languageCode);
                break;

            case LocalizedObjectType.TextAsset:
                languageFolderPath = LocalizationWorkspace.LanguageTextAssetsFolderPathRelative(cultureInfo.languageCode);
                break;

            case LocalizedObjectType.Font:
                languageFolderPath = LocalizationWorkspace.LanguageFontsFolderPathRelative(cultureInfo.languageCode);
                break;
            }

            if (keyType != LocalizedObjectType.GameObject)
            {
                string fileExtension = FileUtility.GetFileExtension(cleanKey, languageFolderPath);
                languageFolderPath += "/" + cleanKey + fileExtension;
            }

            if (FileUtility.Exists(Application.dataPath + languageFolderPath))
            {
                AssetDatabase.DeleteAsset("Assets" + languageFolderPath);
            }
            AssetDatabase.Refresh();
        }
Exemplo n.º 5
0
    void Start()
    {
        thisLanguageManager = LanguageManager.Instance;

        SmartCultureInfo systemLanguage = thisLanguageManager.GetDeviceCultureIfSupported();

        if (thisLanguageManager.IsCultureSupported(systemLanguage))
        {
            thisLanguageManager.ChangeLanguage(systemLanguage);
            //thisLanguageManager.ChangeLanguage("ko-KR");
        }
        thisLanguageManager = LanguageManager.Instance;

        Title.text            = thisLanguageManager.GetTextValue("InApp.Title");
        tenDiamonds.text      = thisLanguageManager.GetTextValue("InApp.Ten");
        thirtyDiamonds.text   = thisLanguageManager.GetTextValue("InApp.Thirty");
        HundredDriamonds.text = thisLanguageManager.GetTextValue("InApp.Hundred");
        ThreeDiamonds.text    = thisLanguageManager.GetTextValue("InApp.Three");
        MostPopular.text      = thisLanguageManager.GetTextValue("InApp.Most");
        BestValue.text        = thisLanguageManager.GetTextValue("InApp.Best");
    }
        public SmartCultureInfo DrawAvailableLanguageItem(Rect position, SmartCultureInfo info)
        {
            if (info.englishName != "ROOT")
            {
                float fullWindowWidth = position.width;
                Rect  newPosition     = position;
                newPosition.width = fullWindowWidth * 0.4f;
                GUI.Label(position, info.englishName + " - " + info.languageCode);

                float buttonWidth = fullWindowWidth * 0.2f;
                buttonWidth = Mathf.Clamp(buttonWidth, 70, 120);

                newPosition.width = buttonWidth;
                newPosition.x     = fullWindowWidth - buttonWidth;

                if (GUI.Button(newPosition, "Update"))
                {
                    LanguageUpdateWindow.ShowWindow(info, this);
                }
                newPosition.x -= buttonWidth;
                if (GUI.Button(newPosition, "Export"))
                {
                    LanguageExportWindow.ShowWindow(info);
                }
                newPosition.x -= buttonWidth;
                if (GUI.Button(newPosition, "Translate"))
                {
                    OnTranslateButtonClick(info);
                }
            }
            else
            {
                position.width += 28;
                if (GUI.Button(position, "Edit Root Language File"))
                {
                    OnRootEditClick();
                }
            }
            return(info);
        }
Exemplo n.º 7
0
        public SmartCultureInfo DrawAvailableLanguageItem(Rect position, SmartCultureInfo info)
        {
            if (info.englishName != "ROOT")
            {
                float fullWindowWidth = position.width;
                Rect  newPosition     = position;
                newPosition.width = fullWindowWidth * 0.4f;
                GUI.Label(position, info.englishName + " - " + info.languageCode);

                float buttonWidth = fullWindowWidth * 0.2f;
                buttonWidth = Mathf.Clamp(buttonWidth, 70, 120);

                newPosition.width = buttonWidth;
                newPosition.x     = fullWindowWidth - buttonWidth;

                if (GUI.Button(newPosition, "Обновить"))
                {
                    LanguageUpdateWindow.ShowWindow(info, this);
                }
                newPosition.x -= buttonWidth;
                if (GUI.Button(newPosition, "Экспорт"))
                {
                    LanguageExportWindow.ShowWindow(info);
                }
                newPosition.x -= buttonWidth;
                if (GUI.Button(newPosition, "Перевести"))
                {
                    OnTranslateButtonClick(info);
                }
            }
            else
            {
                position.width += 28;
                if (GUI.Button(position, "Редактировать файл корневого языка"))
                {
                    OnRootEditClick();
                }
            }
            return(info);
        }
        protected override void OnItemRemoving(ItemRemovingEventArgs args)
        {
            SmartCultureInfoListAdaptor smartAdaptor = args.adaptor as SmartCultureInfoListAdaptor;

            if (smartAdaptor == null)
            {
                return;
            }

            SmartCultureInfo info = smartAdaptor.GetCultureInfo(args.itemIndex);

            if (EditorUtility.DisplayDialog("Удалить " + info.englishName + "?",
                                            "Вы уверены, что хотите удалить " + info.englishName + " и весь его контент из проекта? Вы не сможете отменить это действие.",
                                            "Да, удали это.", "Отмена"))
            {
                LanguageHandlerEditor.DeleteLanguage(info);
                base.OnItemRemoving(args);
            }
            else
            {
                args.Cancel = true;
            }
        }
Exemplo n.º 9
0
    public LocalizationManager()
    {
        languageManager = LanguageManager.Instance;

        SmartCultureInfo systemLanguage = languageManager.GetSupportedSystemLanguage();

        if (systemLanguage != null)
        {
            languageManager.ChangeLanguage(systemLanguage);
        }

        if (languageManager.NumberOfSupportedLanguages > 0)
        {
            currentLanguageValues = languageManager.RawTextDatabase;
            availableLanguages    = languageManager.GetSupportedLanguages();
        }
        else
        {
            Debug.LogError("No languages are created!, Open the Smart Localization plugin at Window->Smart Localization and create your language!");
        }

        LanguageManager.Instance.OnChangeLanguage += OnLanguageChanged;
    }
Exemplo n.º 10
0
    void Start()
    {
        LanguageManager  languageManager = LanguageManager.Instance;
        SmartCultureInfo systemLanguage  = languageManager.GetSupportedSystemLanguage();

        if (systemLanguage != null)
        {
            languageManager.ChangeLanguage(systemLanguage);
        }
        GameObject.Find("Rules").GetComponent <Text> ().text       = languageManager.GetTextValue("Rules");
        GameObject.Find("Goal").GetComponent <Text> ().text        = languageManager.GetTextValue("Goal");
        GameObject.Find("Describe").GetComponent <Text> ().text    = languageManager.GetTextValue("Game Describe");
        GameObject.Find("Positive").GetComponent <Text> ().text    = languageManager.GetTextValue("Positive");
        GameObject.Find("DescribePos").GetComponent <Text> ().text = languageManager.GetTextValue("PositiveDescr");
        GameObject.Find("Negative").GetComponent <Text> ().text    = languageManager.GetTextValue("Negative");
        GameObject.Find("DescribeNeg").GetComponent <Text> ().text = languageManager.GetTextValue("NegativeDescr");
        firstPage  = GameObject.Find("FirstPage");
        secondPage = GameObject.Find("SecondPage");
        thirdPage  = GameObject.Find("ThirdPage");
        next       = GameObject.Find("Next");
        secondPage.SetActive(false);
        thirdPage.SetActive(false);
    }
        protected override void OnItemRemoving(ItemRemovingEventArgs args)
        {
            SmartCultureInfoListAdaptor smartAdaptor = args.adaptor as SmartCultureInfoListAdaptor;

            if (smartAdaptor == null)
            {
                return;
            }

            SmartCultureInfo info = smartAdaptor.GetCultureInfo(args.itemIndex);

            if (EditorUtility.DisplayDialog("Delete " + info.englishName + "?",
                                            "Are you sure you want to delete " + info.englishName + " and all of its content from the project? You cannot undo this action.",
                                            "Yes, delete it.", "Cancel"))
            {
                LanguageHandlerEditor.DeleteLanguage(info);
                base.OnItemRemoving(args);
            }
            else
            {
                args.Cancel = true;
            }
        }
Exemplo n.º 12
0
    void Start()
    {
        thisLanguageManager = LanguageManager.Instance;

        SmartCultureInfo systemLanguage = thisLanguageManager.GetDeviceCultureIfSupported();

        if (thisLanguageManager.IsCultureSupported(systemLanguage))
        {
            thisLanguageManager.ChangeLanguage(systemLanguage);
            //thisLanguageManager.ChangeLanguage("ko-KR");
        }
        thisLanguageManager = LanguageManager.Instance;

        Play.text         = thisLanguageManager.GetTextValue("Menu.Play");
        Upgrades.text     = thisLanguageManager.GetTextValue("Menu.Upgrades");
        Back.text         = thisLanguageManager.GetTextValue("Menu.Back");
        Options.text      = thisLanguageManager.GetTextValue("Menu.Options");
        OptionsLogo.text  = thisLanguageManager.GetTextValue("Menu.Options");
        FreeDiamonds.text = thisLanguageManager.GetTextValue("Menu.Diamonds");
        Diamonds10.text   = thisLanguageManager.GetTextValue("Menu.10Diamonds");
        Diamonds30.text   = thisLanguageManager.GetTextValue("Menu.30Diamonds");
        Diamonds125.text  = thisLanguageManager.GetTextValue("Menu.125Diamonds");
        Diamonds300.text  = thisLanguageManager.GetTextValue("Menu.300Diamonds");
        BestValue.text    = thisLanguageManager.GetTextValue("Menu.BestValue");
        MostPopular.text  = thisLanguageManager.GetTextValue("Menu.MostPopular");
        Games.text        = thisLanguageManager.GetTextValue("Menu.Games");
        OptionsBut.text   = thisLanguageManager.GetTextValue("Menu.Options");
        Achievements.text = thisLanguageManager.GetTextValue("Menu.Achievements");
        Leaderboards.text = thisLanguageManager.GetTextValue("Menu.Leaderboards");
        Connected.text    = thisLanguageManager.GetTextValue("Menu.Connected");
        Credits.text      = thisLanguageManager.GetTextValue("Menu.Credits");
        Reset.text        = thisLanguageManager.GetTextValue("Menu.Reset");
        Yes.text          = thisLanguageManager.GetTextValue("Menu.Yes");
        No.text           = thisLanguageManager.GetTextValue("Menu.No");
        LogoTop.text      = thisLanguageManager.GetTextValue("Menu.LogoTop");
        LogoBot.text      = thisLanguageManager.GetTextValue("Menu.LogoBot");
    }
Exemplo n.º 13
0
    void Start()
    {
        thisLanguageManager = LanguageManager.Instance;

        SmartCultureInfo systemLanguage = thisLanguageManager.GetDeviceCultureIfSupported();

        if (thisLanguageManager.IsCultureSupported(systemLanguage))
        {
            thisLanguageManager.ChangeLanguage(systemLanguage);
            //thisLanguageManager.ChangeLanguage("ko-KR");
        }
        thisLanguageManager = LanguageManager.Instance;

        Continue.text   = thisLanguageManager.GetTextValue("Game.Continue");
        Upgrade.text    = thisLanguageManager.GetTextValue("Game.Upgrade");
        Back.text       = thisLanguageManager.GetTextValue("Menu.Back");
        RateUs.text     = thisLanguageManager.GetTextValue("Results.RateUs");
        Skill.text      = thisLanguageManager.GetTextValue("Game.Skill");
        Score.text      = thisLanguageManager.GetTextValue("Game.Score");
        BonusScore.text = thisLanguageManager.GetTextValue("Results.BonusScore");
        BonusSkill.text = thisLanguageManager.GetTextValue("Results.BonusSkill");
        TotalScore.text = thisLanguageManager.GetTextValue("Results.TotalScore");
        TotalSkill.text = thisLanguageManager.GetTextValue("Results.TotalSkill");
    }
        public SmartCultureInfo DrawCreateLanguageItem(Rect position, SmartCultureInfo info)
        {
            float fullWindowWidth = position.width + 30;
            Rect  newPosition     = position;

            newPosition.width = fullWindowWidth * 0.5f;
            GUI.Label(newPosition, info.englishName + " - " + info.languageCode);

            float buttonWidth = fullWindowWidth * 0.2f;

            newPosition.width = buttonWidth;
            newPosition.x     = fullWindowWidth - newPosition.width;

            if (GUI.Button(newPosition, "Create"))
            {
                OnCreateLanguageClick(info);
            }
            newPosition.x -= buttonWidth;
            if (GUI.Button(newPosition, "Import"))
            {
                LanguageImportWindow.ShowWindow(info, OnInitializeCollectionsCallback);
            }
            return(info);
        }
 public void OnUpdateClick(SmartCultureInfo info)
 {
     Debug.Log("Update: " + info.englishName);
 }
Exemplo n.º 16
0
	/// <summary> Copies the file into the resources folder. Naming the new asset to KEY </summary>
	public static string CopyFileIntoResources(SerializableLocalizationObjectPair objectPair, SmartCultureInfo thisCultureInfo)
	{
		if(!DirectoryUtility.CheckAndCreate(LocalizationWorkspace.LanguageRuntimeFolderPath(thisCultureInfo.languageCode)))
		{
			return "";
		}


		string newFileName = objectPair.keyValue;
		string filePath = string.Empty;
		string currentAssetPath = string.Empty;
		LocalizedObject objectToCopy = objectPair.changedValue;

		if(objectToCopy.ObjectType == LocalizedObjectType.AUDIO && objectToCopy.ThisAudioClip != null)
		{
			filePath = LocalizationWorkspace.LanguageAudioFolderPath(thisCultureInfo.languageCode);
			currentAssetPath = AssetDatabase.GetAssetPath(objectToCopy.ThisAudioClip);
		}
		else if(objectToCopy.ObjectType == LocalizedObjectType.TEXTURE && objectToCopy.ThisTexture != null)
		{
			filePath = LocalizationWorkspace.LanguageTexturesFolderPath(thisCultureInfo.languageCode);
			currentAssetPath = AssetDatabase.GetAssetPath(objectToCopy.ThisTexture);
		}
		else if(objectToCopy.ObjectType == LocalizedObjectType.GAME_OBJECT && objectToCopy.ThisGameObject != null)
		{
			filePath = LocalizationWorkspace.LanguagePrefabsFolderPath(thisCultureInfo.languageCode);
			currentAssetPath = AssetDatabase.GetAssetPath(objectToCopy.ThisGameObject);
		}
		else if(objectToCopy.ObjectType == LocalizedObjectType.TEXT_ASSET && objectToCopy.ThisTextAsset != null)
		{
			filePath = LocalizationWorkspace.LanguageTextAssetsFolderPath(thisCultureInfo.languageCode);
			currentAssetPath = AssetDatabase.GetAssetPath(objectToCopy.ThisTextAsset);
		}
		else if(objectToCopy.ObjectType == LocalizedObjectType.FONT && objectToCopy.Font != null)
		{
			filePath = LocalizationWorkspace.LanguageFontsFolderPath(thisCultureInfo.languageCode);
			currentAssetPath = AssetDatabase.GetAssetPath(objectToCopy.Font);
		}
		else
		{
			return string.Empty;
		}

		if(!DirectoryUtility.CheckAndCreate(filePath))
		{
			return "";
		}

		//Get the fileExtension of the asset
		string fileExtension = FileUtility.GetFileExtension(Application.dataPath + currentAssetPath);
		
		if(objectToCopy.ObjectType != LocalizedObjectType.GAME_OBJECT){
	
			//Copy or replace the file to the new path
			FileUtil.ReplaceFile(currentAssetPath, filePath + "/" + newFileName + fileExtension);
	
			string metaFile = Application.dataPath.Substring(0, Application.dataPath.Length - "Assets".Length) + 
								currentAssetPath.Substring(0, currentAssetPath.Length - fileExtension.Length) + fileExtension + ".meta";
			if(File.Exists(metaFile))
			{
				FileUtil.ReplaceFile(metaFile, filePath + "/" + newFileName + fileExtension + ".meta");
			}
		}
		else{
			string relativePath = filePath + "/" + newFileName + fileExtension;
			relativePath = "Assets" + relativePath.Substring(Application.dataPath.Length);
			PrefabUtility.CreatePrefab(relativePath, objectToCopy.ThisGameObject);
		}

		return AssetDatabase.AssetPathToGUID(currentAssetPath);
	}
 void OnImportClick(SmartCultureInfo info)
 {
 }
 void OnCreateClick(SmartCultureInfo info)
 {
 }
 void ShowTranslateWindow(SmartCultureInfo info)
 {
     translateLanguageWindow = TranslateLanguageWindow.ShowWindow(info, this);
     translateLanguageWindow.InitializeTranslator(automaticTranslator);
     translateLanguageWindow.Show();
 }
 void OnTranslateButtonClick(SmartCultureInfo info)
 {
     //Open language edit window
     ShowTranslateWindow(info);
 }
 void OnDeleteLanguageClick(SmartCultureInfo cultureInfo)
 {
     LanguageHandlerEditor.DeleteLanguage(cultureInfo);
 }
Exemplo n.º 22
0
    void Awake()
    {
        TextAsset dialogAsset;
        TextAsset goalAsset;
        TextAsset colonyAsset;

        isDialogPop = false;
        colonyCount = PlayerPrefs.GetInt("colonyCount");

        LanguageManager  thisLanguageManager = LanguageManager.Instance;
        SmartCultureInfo cultureInfo         = thisLanguageManager.GetSupportedSystemLanguage();

        if (thisLanguageManager.IsLanguageSupportedEnglishName(cultureInfo.englishName))
        {
            thisLanguageManager.ChangeLanguage(cultureInfo.languageCode);
            //thisLanguageManager.ChangeLanguage("fr");
        }
        else
        {
            Debug.Log("Language is not supported");
            thisLanguageManager.ChangeLanguage("en");
        }

        if (cultureInfo.englishName == "Korean")
        {
            dialogAsset = Resources.Load("dialogCollection") as TextAsset;
            goalAsset   = Resources.Load("goalCollection") as TextAsset;
            colonyAsset = Resources.Load("colonyCollection") as TextAsset;
        }
        else
        {
            dialogAsset = Resources.Load("dialogCollection_en") as TextAsset;
            goalAsset   = Resources.Load("goalCollection_en") as TextAsset;
            colonyAsset = Resources.Load("colonyCollection_en") as TextAsset;
        }

        XmlSerializer serializer   = new XmlSerializer(typeof(DialogContainer));
        StringReader  stringReader = new StringReader(dialogAsset.text);
        XmlTextReader xmlReader    = new XmlTextReader(stringReader);

        var container = serializer.Deserialize(xmlReader) as DialogContainer;

        // suck -- already too many static m_dialogs used in other script
        m_Dialogs = new DialogData[container.Dialogs.Length];


        for (int i = 0; i < container.Dialogs.Length; i++)
        {
            m_Dialogs[i].id    = container.Dialogs[i].id;
            m_Dialogs[i].pilot = container.Dialogs[i].pilot;
            m_Dialogs[i].talk  = container.Dialogs[i].Talk;
        }


        // goalAsset = Resources.Load("goalCollection") as TextAsset;

        serializer   = new XmlSerializer(typeof(GoalContainer));
        stringReader = new StringReader(goalAsset.text);
        xmlReader    = new XmlTextReader(stringReader);

        var g_container = serializer.Deserialize(xmlReader) as GoalContainer;

        m_Goals = new GoalData[g_container.Goals.Length];

        for (int i = 0; i < g_container.Goals.Length; i++)
        {
            m_Goals[i].id         = g_container.Goals[i].id;
            m_Goals[i].name       = g_container.Goals[i].name;
            m_Goals[i].distance   = g_container.Goals[i].distance;
            m_Goals[i].reward     = g_container.Goals[i].reward;
            m_Goals[i].rewardText = g_container.Goals[i].RewardText;
        }

        //colonyAsset = Resources.Load("colonyCollection") as TextAsset;

        serializer   = new XmlSerializer(typeof(DialogContainer));
        stringReader = new StringReader(colonyAsset.text);
        xmlReader    = new XmlTextReader(stringReader);

        var c_container = serializer.Deserialize(xmlReader) as DialogContainer;

        // suck -- already too many static m_dialogs used in other script
        colonyDialogs = new DialogData[c_container.Dialogs.Length];


        for (int i = 0; i < container.Dialogs.Length; i++)
        {
            colonyDialogs[i].id    = c_container.Dialogs[i].id;
            colonyDialogs[i].pilot = c_container.Dialogs[i].pilot;
            colonyDialogs[i].talk  = c_container.Dialogs[i].Talk;
        }

        //Debug.Log ("dialog : " + m_Dialogs[1].talk.ToString());
        //Debug.Log (colonyDialogs[1].talk);

        dialogWindow.SetActive(false);

        g_container  = null;
        serializer   = null;
        stringReader = null;
        xmlReader    = null;
        goalAsset    = null;
        dialogAsset  = null;
    }
Exemplo n.º 23
0
        void OnGUI()
        {
            if (LocalizationWindowUtility.ShouldShowWindow(true))
            {
                if (Application.isPlaying)
                {
                    if (currentCultureInfo == null ||
                        (LanguageManager.HasInstance && currentCultureInfo.languageCode != LanguageManager.Instance.CurrentlyLoadedCulture.languageCode))
                    {
                        if (LanguageManager.HasInstance)
                        {
                            SmartCultureInfo currentLanguage = LanguageManager.Instance.GetCultureInfo(LanguageManager.Instance.CurrentlyLoadedCulture.languageCode);
                            if (currentLanguage == null)
                            {
                                return;
                            }

                            Initialize(currentLanguage);
                        }
                        else
                        {
                            GUILayout.Label("В сцене нет LanguageManager. Умное окно перевода локализации не может использоваться во время выполнения без него.", EditorStyles.boldLabel);
                            return;
                        }
                    }
                    else if (rootValues == null && currentCultureInfo != null)
                    {
                        Initialize(currentCultureInfo);
                    }
                }
                else if (rootValues == null)
                {
                    if (currentCultureInfo != null)
                    {
                        Initialize(currentCultureInfo, true);
                    }
                    else
                    {
                        this.Close();
                        return;
                    }
                }

                if (!rootFileChanged)
                {
                    DrawMainTranslationView();
                }
                else
                {
                    //The root file did change, which means that you have to reload. A key might have changed
                    //We can't have language files with different keys
                    GUILayout.Label("Корневой файл мог измениться", EditorStyles.boldLabel);
                    GUILayout.Label("Корневой файл был сохранен, вы должны перезагрузить его. Ключ мог измениться.", EditorStyles.miniLabel);
                    GUILayout.Label("Вы не можете иметь языковые файлы с разными ключами", EditorStyles.miniLabel);
                    if (GUILayout.Button("Перезагрузить языковой файл"))
                    {
                        ReloadLanguage();
                    }
                }
            }
        }
Exemplo n.º 24
0
        void OnGUI()
        {
            if (LocalizationWindowUtility.ShouldShowWindow())
            {
                GUILayout.Label("Create a new culture info", EditorStyles.boldLabel);

                languageCode = EditorGUILayout.TextField("Language Code", languageCode);
                if (languageCode != null)
                {
                    languageCode = languageCode.RemoveWhitespace();
                }

                englishName   = EditorGUILayout.TextField("English Name", englishName);
                nativeName    = EditorGUILayout.TextField("Native Name", nativeName);
                isRightToLeft = EditorGUILayout.Toggle("Is Right To Left", isRightToLeft);

                if (GUILayout.Button("Create"))
                {
                    SmartCultureInfo newInfo = new SmartCultureInfo();
                    newInfo.languageCode  = languageCode;
                    newInfo.englishName   = englishName.Trim();
                    newInfo.nativeName    = nativeName.Trim();
                    newInfo.isRightToLeft = isRightToLeft;

                    SmartCultureInfoCollection allCultures = SmartCultureInfoEx.Deserialize(LocalizationWorkspace.CultureInfoCollectionFilePath());
                    if (!allCultures.IsCultureInCollection(newInfo))
                    {
                        allCultures.AddCultureInfo(newInfo);
                        allCultures.Serialize(LocalizationWorkspace.CultureInfoCollectionFilePath());
                        LanguageHandlerEditor.CheckAndSaveAvailableLanguages(allCultures);

                        showHelpMessage = true;
                        helpMessageType = MessageType.Info;
                        helpMessage     = string.Format("Successfully created language!\n Language Code: {0}\n English Name:{1}\n Native Name:{2}\n IsRightToLeft:{3}",
                                                        newInfo.languageCode, newInfo.englishName, newInfo.nativeName, newInfo.isRightToLeft);

                        if (parentWindow != null)
                        {
                            parentWindow.InitializeCultureCollections(true);
                        }

                        this.Close();
                    }
                    else
                    {
                        SmartCultureInfo conflictingCulture  = allCultures.FindCulture(newInfo);
                        string           conflictingVariable = null;

                        if (conflictingCulture.languageCode.ToLower() == newInfo.languageCode.ToLower())
                        {
                            conflictingVariable = "Language Code:" + newInfo.languageCode;
                        }
                        else if (conflictingCulture.englishName.ToLower() == newInfo.englishName.ToLower())
                        {
                            conflictingVariable = "English Name:" + newInfo.englishName;
                        }

                        showHelpMessage = true;
                        helpMessageType = MessageType.Error;
                        helpMessage     = string.Format("Failed to create language!\n Conflicting variable - {0}\n\n",
                                                        conflictingVariable);

                        helpMessage += string.Format("Conflicting Culture \n Language Code: {0}\n English Name:{1}\n Native Name:{2}",
                                                     conflictingCulture.languageCode, conflictingCulture.englishName, conflictingCulture.nativeName);
                    }
                }

                if (showHelpMessage)
                {
                    EditorGUILayout.HelpBox(helpMessage, helpMessageType);
                }
            }
        }
Exemplo n.º 25
0
        void OnGUI()
        {
            if (LocalizationWindowUtility.ShouldShowWindow())
            {
                GUILayout.Label("Создать новую информацию о культуре", EditorStyles.boldLabel);

                languageCode = EditorGUILayout.TextField("Код языка", languageCode);
                if (languageCode != null)
                {
                    languageCode = languageCode.RemoveWhitespace();
                }

                englishName   = EditorGUILayout.TextField("Английское имя", englishName);
                nativeName    = EditorGUILayout.TextField("Родное имя", nativeName);
                isRightToLeft = EditorGUILayout.Toggle("Справа налево", isRightToLeft);

                if (GUILayout.Button("Создать"))
                {
                    SmartCultureInfo newInfo = new SmartCultureInfo();
                    newInfo.languageCode  = languageCode;
                    newInfo.englishName   = englishName.Trim();
                    newInfo.nativeName    = nativeName.Trim();
                    newInfo.isRightToLeft = isRightToLeft;

                    SmartCultureInfoCollection allCultures = SmartCultureInfoEx.Deserialize(LocalizationWorkspace.CultureInfoCollectionFilePath());
                    if (!allCultures.IsCultureInCollection(newInfo))
                    {
                        allCultures.AddCultureInfo(newInfo);
                        allCultures.Serialize(LocalizationWorkspace.CultureInfoCollectionFilePath());
                        LanguageHandlerEditor.CheckAndSaveAvailableLanguages(allCultures);

                        showHelpMessage = true;
                        helpMessageType = MessageType.Info;
                        helpMessage     = string.Format("Язык успешно создан!\n Код языка: {0}\n Английское имя:{1}\n Родное имя:{2}\n Справа налево:{3}",
                                                        newInfo.languageCode, newInfo.englishName, newInfo.nativeName, newInfo.isRightToLeft);

                        if (parentWindow != null)
                        {
                            parentWindow.InitializeCultureCollections(true);
                        }

                        this.Close();
                    }
                    else
                    {
                        SmartCultureInfo conflictingCulture  = allCultures.FindCulture(newInfo);
                        string           conflictingVariable = null;

                        if (conflictingCulture.languageCode.ToLower() == newInfo.languageCode.ToLower())
                        {
                            conflictingVariable = "Language Code:" + newInfo.languageCode;
                        }
                        else if (conflictingCulture.englishName.ToLower() == newInfo.englishName.ToLower())
                        {
                            conflictingVariable = "English Name:" + newInfo.englishName;
                        }

                        showHelpMessage = true;
                        helpMessageType = MessageType.Error;
                        helpMessage     = string.Format("Не удалось создать язык!\n Конфликтующая переменная - {0}\n\n",
                                                        conflictingVariable);

                        helpMessage += string.Format("Конфликтующая культура \n Код языка: {0}\n Английское имя:{1}\n Родное имя:{2}",
                                                     conflictingCulture.languageCode, conflictingCulture.englishName, conflictingCulture.nativeName);
                    }
                }

                if (showHelpMessage)
                {
                    EditorGUILayout.HelpBox(helpMessage, helpMessageType);
                }
            }
        }
Exemplo n.º 26
0
    void Awake()
    {
        starAlbum = new StarAlbum[88];

        unlockLevel = PlayerPrefs.GetInt("unlockLevel");

        if (unlockLevel == 0)
        {
            unlockLevel = 1;
        }

        var data = PlayerPrefs.GetString("starAlbum");

        if (!String.IsNullOrEmpty(data))
        {
            var b = new BinaryFormatter();
            var m = new MemoryStream(Convert.FromBase64String(data));

            starAlbum = b.Deserialize(m) as StarAlbum[];
        }

        LanguageManager  thisLanguageManager = LanguageManager.Instance;
        SmartCultureInfo cultureInfo         = thisLanguageManager.GetSupportedSystemLanguage();

//		if(thisLanguageManager.IsLanguageSupportedEnglishName(cultureInfo.englishName))
//		{
//			thisLanguageManager.ChangeLanguage(cultureInfo.languageCode);
//			//thisLanguageManager.ChangeLanguage("fr");
//		}
//		else
//		{
//			Debug.Log("Language is not supported");
//			thisLanguageManager.ChangeLanguage("en");
//		}

        if (cultureInfo.englishName == "Korean")
        {
            starAsset = Resources.Load("starCollection") as TextAsset;
        }
        else
        {
            starAsset = Resources.Load("starCollection_en") as TextAsset;
        }

        //starAsset = Resources.Load("starCollection") as TextAsset;

        XmlSerializer serializer   = new XmlSerializer(typeof(StarContainer));
        StringReader  stringReader = new StringReader(starAsset.text);
        XmlTextReader xmlReader    = new XmlTextReader(stringReader);

        var container = serializer.Deserialize(xmlReader) as StarContainer;

        stringReader.Close();

        stars = new StarData[container.stars.Length];

        for (int i = 0; i < container.stars.Length; i++)
        {
            stars[i].id     = container.stars[i].id;
            stars[i].level  = container.stars[i].level;
            stars[i].name   = container.stars[i].name;
            stars[i].sprite = Resources.Load <Sprite>("Constellation/" + container.stars[i].filename);
            stars[i].desc   = container.stars[i].Desc;
        }

        serializer   = null;
        stringReader = null;
        xmlReader    = null;
        container    = null;
        starAsset    = null;
    }
 public void OnExportClick(SmartCultureInfo info)
 {
     Debug.Log("Export: " + info.englishName);
 }
Exemplo n.º 28
0
        void OnGUI()
        {
            if (LocalizationWindowUtility.ShouldShowWindow(true))
            {
                if (Application.isPlaying)
                {
                    if (currentCultureInfo == null ||
                        (LanguageManager.HasInstance && currentCultureInfo.languageCode != LanguageManager.Instance.CurrentlyLoadedCulture.languageCode))
                    {
                        if (LanguageManager.HasInstance)
                        {
                            SmartCultureInfo currentLanguage = LanguageManager.Instance.GetCultureInfo(LanguageManager.Instance.CurrentlyLoadedCulture.languageCode);
                            if (currentLanguage == null)
                            {
                                return;
                            }

                            Initialize(currentLanguage);
                        }
                        else
                        {
                            GUILayout.Label("There is no LanguageManager in the scene. Smart Localization Translation Window cannot be used at runtime without it.", EditorStyles.boldLabel);
                            return;
                        }
                    }
                    else if (rootValues == null && currentCultureInfo != null)
                    {
                        Initialize(currentCultureInfo);
                    }
                }
                else if (rootValues == null)
                {
                    if (currentCultureInfo != null)
                    {
                        Initialize(currentCultureInfo, true);
                    }
                    else
                    {
                        this.Close();
                        return;
                    }
                }

                if (!rootFileChanged)
                {
                    DrawMainTranslationView();
                }
                else
                {
                    //The root file did change, which means that you have to reload. A key might have changed
                    //We can't have language files with different keys
                    GUILayout.Label("The root file might have changed", EditorStyles.boldLabel);
                    GUILayout.Label("The root file did save, which means that you have to reload. A key might have changed.", EditorStyles.miniLabel);
                    GUILayout.Label("You can't have language files with different keys", EditorStyles.miniLabel);
                    if (GUILayout.Button("Reload Language File"))
                    {
                        ReloadLanguage();
                    }
                }
            }
        }
Exemplo n.º 29
0
        public void Initialize(SmartCultureInfo thisCultureInfo, bool forceNewLanguage = false)
        {
            if (thisCultureInfo != null)
            {
                if (undoManager == null)
                {
                    // Instantiate Undo Manager
                    undoManager = new HOEditorUndoManager(this, "Smart Localization - Translate Language Window");
                }

                if (thisCultureInfo != null)
                {
                    bool newLanguage = thisCultureInfo != this.currentCultureInfo ? true : false;

                    if (Application.isPlaying || forceNewLanguage)
                    {
                        newLanguage = true;
                    }

                    this.currentCultureInfo = thisCultureInfo;
                    if (loadedLanguageValues == null || loadedLanguageValues.Count < 1 || newLanguage)
                    {
                        InitializeLanguage(thisCultureInfo,
                                           LanguageHandlerEditor.LoadParsedLanguageFile(null, true),
                                           LanguageHandlerEditor.LoadParsedLanguageFile(thisCultureInfo.languageCode,
                                                                                        false));
                    }
                }

                settingsList.Clear();
                settingsList.Add("SETTINGS");
                settingsList.Add("CONVERTLINEBREAK");
                settingsList.Add("WATCHFILE");
                settingsList.Add("AUTOTRANSLATE");
                settingsList.Add("GENERAL");

#if UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3
                if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.WebPlayer &&
                    EditorUserBuildSettings.activeBuildTarget != BuildTarget.WebPlayerStreamed)
#endif
                {
                    settingsList.Add("SORT");
                }

                settingsList.Add("SEARCH");

                settingsAdaptor     = new SettingsListAdaptor(settingsList, DrawSettingsItem, 20);
                settingsContextMenu = new SettingsMenuControl();

                listColumns = new EditorColumns(0.02f, true);
                listColumns.AddColumn("Copy", 0.1f);
                listColumns.AddColumn("Translate", 0.1f);
                listColumns.AddColumn("Key", 0.21f);
                listColumns.AddColumn("Comment", 0.21f);
                listColumns.AddColumn("Override", 0.07f);
                listColumns.AddColumn("Value", 0.25f);
                listColumns.RecalculateColumnWidths();

                if (EditorPrefs.HasKey(CollapseMultilineSaveKey))
                {
                    collapseMultilineFields = EditorPrefs.GetBool(CollapseMultilineSaveKey);
                }

                GUIUtility.keyboardControl = 0;

                SmartCultureInfoCollection allCultures       = SmartCultureInfoEx.Deserialize(LocalizationWorkspace.CultureInfoCollectionFilePath());
                SmartCultureInfoCollection availableCultures = LanguageHandlerEditor.CheckAndSaveAvailableLanguages(allCultures);
                otherAvailableLanguageCodes.Clear();
                otherAvailableLanguageCodesArray = null;
                foreach (SmartCultureInfo otherCulture in availableCultures.cultureInfos)
                {
                    if (otherCulture.languageCode != thisCultureInfo.languageCode)
                    {
                        otherAvailableLanguageCodes.Add(otherCulture.languageCode);
                    }
                }

                if (otherAvailableLanguageCodes.Count > 0)
                {
                    otherAvailableLanguageCodesArray = otherAvailableLanguageCodes.ToArray();
                }
            }
        }