Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (Dialogue.Curent == "")
        {
            canva.enabled = false;
        }
        else
        {
            canva.enabled = true;

            if (Dialogue.dialogue.icone != null)
            {
                icon.sprite = Dialogue.dialogue.icone;
            }

            lang curLang = lang.findLang(PlayerPrefs.GetString("lang", "Eng"), Dialogue.dialogue.group);

            txt.text = curLang.findText(Dialogue.dialogue.key).value;

            if (Input.GetButton("Submit") && TimeLef >= 0.2f)
            {
                Dialogue.Curent = Dialogue.dialogue.next;
                TimeLef         = 0;
            }
            else
            {
                TimeLef += Time.deltaTime;
            }
        }
    }
Beispiel #2
0
    public static async Task <TranslateResponse> TranslateText(string input, lang langInput = lang.auto, lang langOutput = lang.zh_CN)
    {
        var res = new TranslateResponse();

        try
        {
            var          client   = new HttpClient();
            const string sl       = "auto";
            var          tl       = langOutput.ToString().Replace("_", "-");
            var          hl       = langInput.ToString().Replace("_", "-");
            var          url      = $"https://translate.googleapis.com/translate_a/single?client=gtx&sl={sl}&tl={tl}&hl={hl}&dt=t&dt=bd&dj=1&source=input&tk=501776.501776&q={input}";
            var          response = await client.GetAsync(url);

            if (response.IsSuccessStatusCode)
            {
                var text = await response.Content.ReadAsStringAsync();

                var translateResult = JsonConvert.DeserializeObject <TranslateResult>(text);
                res.IsSuccess = true;
                res.Result    = translateResult;
                res.Response  = text;
            }
        }
        catch (Exception ex)
        {
            Debug.WriteLine("GoogleTranslateLib.Translate [error] = " + ex);
            res.IsSuccess    = false;
            res.Exception    = ex;
            res.MessageError = ex.Message;
        }
        return(res);
    }
 public static int CreateProjectLanguages(int projectId, string[] languages)
 {
     foreach (var code in languages)
     {
         var lang = new lang {
             project_id = projectId, code = code
         };
         _context.langs.AddObject(lang);
     }
     return(_context.SaveChanges());
 }
Beispiel #4
0
 void LangLoad() // метод перевода
 {
     json               = File.ReadAllText(Application.streamingAssetsPath + "/Languages/" + PlayerPrefs.GetString("Language") + ".json");
     lng                = JsonUtility.FromJson <lang>(json);
     T_Namegame.text    = lng.namegame;
     T_ChangeLng.text   = lng.changelng;
     T_BttnLang1.text   = lng.language[0];
     T_BttnLang2.text   = lng.language[1];
     T_Choose.text      = lng.choose;
     T_Questionlng.text = lng.questionlng;
     T_Yes.text         = lng.yes;
     T_No.text          = lng.no;
 }
Beispiel #5
0
    private void onButtonSaveClick()
    {
        state_nickname = nickInputField.text;
        nickText.text  = nickInputField.text;

        if (languageField.value == 0)
        {
            state_language = lang.RUSSIAN;
        }
        else
        {
            state_language = lang.ENGLISH;
        }

        if (state_language == lang.ENGLISH)
        {
            titleText.text = "Gamer data:";
            typeText.text  = "Level";
            type1Text.text = "Coins";
            type2Text.text = "Crystals";
            type3Text.text = "Energy";
            type4Text.text = "Inventory";
            type5Text.text = "Consumables";
            type6Text.text = "Skill";
            type7Text.text = "Payed";
            type8Text.text = "Paying";
            type9Text.text = "Banned";
        }
        else
        {
            titleText.text = "Данные игрока:";
            typeText.text  = "Уровень";
            type1Text.text = "Монеты";
            type2Text.text = "Кристаллы";
            type3Text.text = "Энергия";
            type4Text.text = "Инвентарь";
            type5Text.text = "Расходники";
            type6Text.text = "Мастерство";
            type7Text.text = "Оставил денег";
            type8Text.text = "Платящий";
            type9Text.text = "Забанен";
        }

        string nick        = nickInputField.text;
        string currentLang = (state_language == main.lang.ENGLISH) ? "english" : "russian";
        string facebook    = (facebookField.value == 0) ? "true" : "false";
        string apple       = (appleField.value == 0) ? "true" : "false";
        string google      = (googleField.value == 0) ? "true" : "false";

        StartCoroutine(addRequestPOST(nick, currentLang, facebook, apple, google));
    }
Beispiel #6
0
        public static async Task <TranslateResult> TranslateText(string input, lang lang_in = lang.en, lang lang_out = lang.vi,
                                                                 string TemplateRequest     = "https://translate.google.com/translate_a/single?client=webapp&sl={lang_in}&tl={lang_out}&hl=vi&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&pc=1&otf=1&ssel=3&tsel=3&kc=1&tk={tk}&q={input}")
        {
            var r = new TranslateResult
            {
                IsSuccess    = false,
                lang_in      = lang_in,
                lang_out     = lang_out,
                Text_in      = input,
                Text_out     = input,
                ResponseCode = null
            };

            try
            {
                string tk  = computed_tk(input);
                string url = TemplateRequest
                             .Replace("{lang_in}", lang_in.ToString())
                             .Replace("{lang_out}", lang_out.ToString())
                             .Replace("{tk}", tk.ToString())
                             .Replace("{input}", Uri.EscapeUriString(input));
                Debug.WriteLine(url);

                var client  = new RestClient(url);
                var request = new RestRequest(Method.GET);
                foreach (var item in cookies)
                {
                    request.AddCookie(item.Name, item.Value);
                }
                var restResponse = await client.ExecuteTaskAsync(request);

                r.ResponseCode = restResponse.StatusCode;
                r.ResponseText = restResponse.Content;
                if (r.ResponseCode == HttpStatusCode.OK)
                {
                    r.IsSuccess = true;
                    r.Text_out  = Regex.Match(r.ResponseText, "\\[\\[\\[\"([^\"]+)").Groups[1].Value;
                }
                else
                {
                    Count_fail++;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(input + ": " + ex);
            }
            return(r);
        }
Beispiel #7
0
    private void LangLoad()
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        string path   = Path.Combine(Application.streamingAssetsPath, "Languages/" + PlayerPrefs.GetString("Language") + ".json");
        WWW    reader = new WWW(path);
        while (!reader.isDone)
        {
        }
        json = reader.text;
#else
        json = File.ReadAllText(Application.streamingAssetsPath + "/Languages/" + PlayerPrefs.GetString("Language") + ".json");
#endif

        lng = JsonUtility.FromJson <lang>(json);
        Translator();
        setPrice();
    }
Beispiel #8
0
        public void read()
        {
            var configFile = File.ReadAllLines("config.bin");

            foreach (var line in configFile)
            {
                //Read language
                if (line.Contains("Lang: 1"))
                {
                    userLanguage = lang.español;
                }
                else if (line.Contains("Lang: 0"))
                {
                    userLanguage = lang.english;
                }
            }
        }
Beispiel #9
0
    private void loadMainScreen(int newId, string newNick, lang newLang)
    {
        if (accountId.isValid)
        {
            PlayerPrefs.SetInt("AccountId", newId);
            PlayerPrefs.SetString("Nickname", newNick);
            PlayerPrefs.SetInt("Language", (int)newLang);
            PlayerPrefs.Save();

            welcomeScreen.SetActive(false);
            mainScreen.SetActive(true);
        }
        else
        {
            Debug.Log("ERROR: can not load main screen!");
        }
    }
Beispiel #10
0
    void LangLoad()
    {
        //TextAsset filejson = Resources.Load<TextAsset>(PlayerPrefs.GetString("Language"));
        //        lng = JsonUtility.FromJson<lang>(filejson.text);

#if UNITY_ANDROID && !UNITY_EDITOR
        string path   = Path.Combine(Application.streamingAssetsPath, "Languages/" + PlayerPrefs.GetString("Language") + ".json");
        WWW    reader = new WWW(path);
        while (!reader.isDone)
        {
        }
        json = reader.text;
        lng  = JsonUtility.FromJson <lang>(json);
#endif
#if UNITY_EDITOR
        json = File.ReadAllText(Application.streamingAssetsPath + "/Languages/" + PlayerPrefs.GetString("Language") + ".json");
        lng  = JsonUtility.FromJson <lang>(json);
        print(PlayerPrefs.GetString("Language"));
#endif
    }
Beispiel #11
0
    private void onButtonResetClick()
    {
        resetDataFromDisk(true);

        state_id       = -1;
        state_language = lang.RUSSIAN;
        state_nickname = "";

        languageField.value = 0;
        facebookField.value = 0;
        appleField.value    = 0;
        googleField.value   = 0;

        nickInputField.text     = "";
        buttonSave.interactable = false;

        welcomeScreen.SetActive(true);
        mainScreen.SetActive(false);

        Debug.Log("ACCOUNT ID: " + state_id);
    }
Beispiel #12
0
 set => this.SetString(lang, value);
Beispiel #13
0
    void Start()
    {
        urlServer = urlWebServer;
        StartCoroutine(tokenRequestGET());

        if (PlayerPrefs.HasKey("AccountId"))
        {
            state_id       = PlayerPrefs.GetInt("AccountId");
            state_nickname = PlayerPrefs.GetString("Nickname");

            nickText.text = state_nickname;

            if (PlayerPrefs.GetInt("Language") == 0)
            {
                state_language = lang.RUSSIAN;
            }
            else
            {
                state_language = lang.ENGLISH;
            }

            if (state_language == lang.ENGLISH)
            {
                titleText.text = "Gamer data:";
                typeText.text  = "Level";
                type1Text.text = "Coins";
                type2Text.text = "Crystals";
                type3Text.text = "Energy";
                type4Text.text = "Inventory";
                type5Text.text = "Consumables";
                type6Text.text = "Skill";
                type7Text.text = "Payed";
                type8Text.text = "Paying";
                type9Text.text = "Banned";
            }
            else
            {
                titleText.text = "Данные игрока:";
                typeText.text  = "Уровень";
                type1Text.text = "Монеты";
                type2Text.text = "Кристаллы";
                type3Text.text = "Энергия";
                type4Text.text = "Инвентарь";
                type5Text.text = "Расходники";
                type6Text.text = "Мастерство";
                type7Text.text = "Оставил денег";
                type8Text.text = "Платящий";
                type9Text.text = "Забанен";
            }

            welcomeScreen.SetActive(false);
            mainScreen.SetActive(true);

            StartCoroutine(infoRequestGET(state_id));
        }
        else
        {
            state_id = -1;
            welcomeScreen.SetActive(true);
            mainScreen.SetActive(false);

            buttonSave.interactable = false;
        }

        Debug.Log("ACCOUNT ID: " + state_id);

        registration();
    }
 /// <summary>
 /// Deprecated Method for adding a new object to the langs EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTolangs(lang lang)
 {
     base.AddObject("langs", lang);
 }
Beispiel #15
0
 public void setLanguage(lang language)
 {
     userLanguage = language;
 }
Beispiel #16
0
 set => SetName(lang, value);
Beispiel #17
0
 void LangLoad()//МЕТОД ДЛЯ ПРИСВАЕНИЯ ФАЙЛА (JSON) В ПЕРЕМЕНУЮ
 {
     json = File.ReadAllText(Application.streamingAssetsPath + "/Languages/" + PlayerPrefs.GetString("Languages") + ".json");
     lng  = JsonUtility.FromJson <lang>(json);
     Debug.Log(lng.menu[0]);
 }
 async Task _testInOut(lang lang_input, string input, lang lang_output, string output)
 {
     Assert.AreEqual(output, (await Translate.TranslateText(input, lang_input, lang_output)).Result.sentences[0].trans);
 }
 /// <summary>
 /// Create a new lang object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 public static lang Createlang(global::System.Int32 id)
 {
     lang lang = new lang();
     lang.id = id;
     return lang;
 }