Ejemplo n.º 1
0
        private void AddTranslation(string originalText)
        {
            if (string.IsNullOrWhiteSpace(originalText))
            {
                return;
            }
            Translatable translatable = _configuration.Translatables.Add();

            translatable.Name = originalText;
            foreach (var language in _configuration.Languages)
            {
                var         translatedResult = _translationClient.TranslateText($"{originalText}", $"{language.Code}");
                Translation translation      = translatable.Translations.Add();
                translation.Language       = language;
                translation.TranslatedText = translatedResult.TranslatedText;
            }
        }
Ejemplo n.º 2
0
        protected Culture DefineLanguage(HttpContextBase context)
        {
            var cookie = context.Request.Cookies["UserLang"];

            if (cookie != null)
            {
                Language.Culture = new CultureInfo(cookie.Value);
            }
            else
            {
                Language.Culture = new CultureInfo("en");
                cookie           = new HttpCookie("UserLang")
                {
                    Value   = "en",
                    Expires = DateTime.MaxValue
                };
                context.Response.Cookies.Remove("UserLang");
                context.Response.SetCookie(cookie);
            }
            return(Translatable.DefineCulture(Language.Culture.TwoLetterISOLanguageName));
        }
Ejemplo n.º 3
0
    /// <summary>
    /// uses Repository, Toast, Controller
    /// this require server assertion
    /// </summary>
    private async UniTask TryUnlock()
    {
        //client assertion
        if (State != ShopItemState.Locked)
        {
            Debug.LogError(
                $"cardback with index {id} is already unlocked or set, what the f**k you're doing");
            return;
        }
        if (Repository.I.PersonalFullInfo.Money < price)
        {
            Toast.I.Show(Translatable.GetText("no_money"), 2);
            return;
        }

        await Controller.I.BuyItem(Shop.Active.ItemType, id);

        //stop interaction? it depends on whether interacting will create issues or not.
        //and usually it will
        //await feedback
        //(1) block all interactions
        //(2) block this item only
        //unless you have a mechanism for blocking individual items easily(which is not true)
        //for example closing and reopening the panel will discard the blocking!

        //if I am here, the server assured

        if (Shop.Active.ItemType == ItemType.Cardback)
        {
            Repository.I.PersonalFullInfo.OwnedCardBackIds.Add(id);
        }
        else
        {
            Repository.I.PersonalFullInfo.OwnedBackgroundsIds.Add(id);
        }

        Repository.I.PersonalFullInfo.Money -= price; //propagate visually

        SetState(ShopItemState.Unlocked);             //change the visuals also
    }
        public static void AddFromFile(string path)
        {
            var text = DocumentService.FromFile(path);

            var rows = text.Split("\n")
                       .Where(pair => !pair.Equals("\r"))
                       .Where(pair => !pair.Equals(string.Empty));
            var originals    = rows.Where((row, index) => index % 2 == 0);
            var translations = rows.Where((row, index) => index % 2 != 0);

            var translatables = originals.Select((original, index) =>
            {
                var partOfSpeech     = Regex.Match(original, PartOfSpeech.Regex).Value;
                var originalAdjusted = original;

                if (!partOfSpeech.Equals(string.Empty))
                {
                    originalAdjusted = original.Replace(partOfSpeech, string.Empty).Trim();
                }
                else
                {
                    partOfSpeech = null;
                }

                var translatable = new Translatable
                {
                    Original     = originalAdjusted.Replace("\r", string.Empty),
                    Translated   = translations.ElementAt(index).Replace("\r", string.Empty),
                    PartOfSpeech = partOfSpeech
                };

                return(translatable);
            });

            foreach (var translatable in translatables)
            {
                MongoDBConnector.Add(translatable);
            }
        }
Ejemplo n.º 5
0
    public override void OnInspectorGUI()
    {
        Translatable myTarget = (Translatable)target;

        // Call files
        myTarget.id   = EditorGUILayout.TextField("ID", myTarget.id);
        myTarget.text = EditorGUILayout.TextField("Text", myTarget.text);

        myTarget.GetFiles();
        myTarget.selected = EditorGUILayout.Popup(myTarget.selected, myTarget.options);

        if (GUILayout.Button("Update JSON File with Text Component"))
        {
            // Finds the text component of the Game Object and corresponding file
            string fileNameComponent = myTarget.id;

            string textComponent = myTarget.text;
            string selectedFile  = myTarget.options[myTarget.selected];

            myTarget.UpdateJSON(selectedFile, fileNameComponent, textComponent);
            Debug.Log("File was updated with text component.");
        }
    }
Ejemplo n.º 6
0
    public void Challenge()
    {
        if (Repository.I.PersonalFullInfo.Money < RoomSettings.MinBet)
        {
            Toast.I.Show(Translatable.GetText("no_money"));
        }

        UniTask.Create(async() =>
        {
            var res = await Controller.I.InvokeAsync <MatchRequestResult>("RequestMatch", Id);

            if (res == MatchRequestResult.Available)
            {
                BlockingPanel.Show("a challenge request is sent to the player",
                                   () => Controller.I.Send("CancelChallengeRequest"))
                .Forget(e => throw e);
            }
            else
            {
                Toast.I.Show(res.ToString());
            }
        });
    }
Ejemplo n.º 7
0
 /// <summary>
 ///   表の最後の行のHTMLを出力する。表示行数選択肢指定バージョン。
 /// </summary>
 public StringBuilder GetLastRow(Translatable page, StringBuilder text, int n, string url, int lines, int[] lineselections)
 {
     text.Append("<tr class='list_last'><td colspan='");
     text.Append(GetColumns().ToString());
     text.Append("'>\n");
     if ((url != null) && (url != ""))
     {
         text.Append("<div class='float_right'>\n");
         text.Append(page._("表示行数変更:"));
         text.Append("<select name=\"lines\" onchange=\"this.form.action='");
         text.Append(url);
         text.Append("'; this.form.submit();\">");
         foreach (int i in lineselections)
         {
             text.Append("<option value='");
             text.Append(i.ToString());
             text.Append("'");
             if (i == lines)
             {
                 text.Append(" selected='selected'");
             }
             text.Append(">");
             text.Append(i.ToString());
             text.Append("</option>");
         }
         text.Append("</select>\n");
         text.Append("</div>\n");
     }
     if (n > 0)
     {
         text.Append(string.Format(page._("...他{0}件"), n.ToString()));
         text.Append("\n");
     }
     text.Append("</td></tr>\n");
     return(text);
 }
Ejemplo n.º 8
0
    //visual state is updated, this has nothing to do with visuals
    public void OnClick()
    {
        var info = Repository.I.PersonalFullInfo;

        if (info.MoneyAimTimePassed >= ConstData.MoneyAimTime)
        {
            Controller.I.SendAsync("ClaimMoneyAid");

            info.MoneyAimTimePassed = null;
            info.Money += RoomSettings.MinBet;

            UpdateState();
        } //claimable
        else if (info.MoneyAimTimePassed != null)
        {
            Toast.I.Show(Translatable.GetText("wait_time"));
        } //pending
        else if (info.MoneyAidRequested >= 4)
        {
            Toast.I.Show(Translatable.GetText("daily_limit"));
        } //max requests reached
        else if (info.Money >= RoomSettings.MinBet) //from here MoneyAimTimeLeft = null for sure
        {
            Toast.I.Show(Translatable.GetText("already_money"));
        } //can't ask, a lot of money
        else
        {
            Controller.I.SendAsync("AskForMoneyAid");

            info.MoneyAimTimePassed = 0;
            info.DecreaseMoneyAimTimeLeft().Forget();
            info.MoneyAidRequested++;

            UpdateState();
        } //ask
    }
Ejemplo n.º 9
0
 /// <summary>
 ///   コンストラクタ
 /// </summary>
 public CheckBox(string name, string text, object value, Translatable tr) : base(name, tr)
 {
     Text  = text;
     Value = value;
 }
Ejemplo n.º 10
0
 /// <summary>
 ///   ソート変更アンカー付きのテーブルヘッダHTML文字列を作成する。
 /// </summary>
 public StringBuilder GetSortableHeader(Translatable page, StringBuilder text, string sorttype, string sortorder, string url)
 {
     text.Append("<thead>\n");
     text.Append("<tr class='head'>\n");
     foreach (List <CellDef> column in celldefs)
     {
         int ncell = 0;
         foreach (CellDef cell in column)
         {
             if ((cell.recordname != null) && (cell.recordname != "") && (cell.style != CellDef.Style.HIDE))
             {
                 ncell++;
             }
         }
         if (ncell == 0)
         {
             continue;
         }
         text.Append("<th>");
         foreach (CellDef cell in column)
         {
             if ((cell.recordname == null) || (cell.recordname == "") || (cell.style == CellDef.Style.HIDE))
             {
                 continue;
             }
             if (cell.style == CellDef.Style.SUBINFO)
             {
                 text.Append("<div class='subinfo'>");
             }
             else if (cell.style == CellDef.Style.OPERATION)
             {
                 text.Append("<div class='operation'>");
             }
             if (cell.sortable == CellDef.Sortable.NONE)
             {
                 cell.GetHtmlDisplayName(page, text);
             }
             else if (cell.recordname == sorttype)
             {
                 text.Append("<a href=\"");
                 text.Append(url);
                 if (url.Contains("?"))
                 {
                     text.Append("&");
                 }
                 else
                 {
                     text.Append("?");
                 }
                 text.Append("sort_order=");
                 if (sortorder == "ascend")
                 {
                     text.Append("descend\">");
                     cell.GetHtmlDisplayName(page, text);
                     text.Append("▼</a>");
                 }
                 else
                 {
                     text.Append("ascend\">");
                     cell.GetHtmlDisplayName(page, text);
                     text.Append("▲</a>");
                 }
             }
             else
             {
                 text.Append("<a href=\"");
                 text.Append(url);
                 if (url.Contains("?"))
                 {
                     text.Append("&");
                 }
                 else
                 {
                     text.Append("?");
                 }
                 text.Append("sort_type=");
                 text.Append(cell.recordname);
                 text.Append("&sort_order=");
                 text.Append((cell.sortable == CellDef.Sortable.ASCEND)?"ascend" : "descend");
                 text.Append("\">");
                 cell.GetHtmlDisplayName(page, text);
                 text.Append("</a>");
             }
             if (cell.style != CellDef.Style.NORMAL)
             {
                 text.Append("</div>");
             }
         }
         text.Append("</th>\n");
     }
     text.Append("</tr>\n");
     return(text);
 }
Ejemplo n.º 11
0
 /// <summary>
 ///   表の最後の行のHTMLを出力する。
 /// </summary>
 public StringBuilder GetLastRow(Translatable page, StringBuilder text, int n, string url, int lines)
 {
     return(GetLastRow(page, text, n, url, lines, default_lineselections));
 }
Ejemplo n.º 12
0
 /// <summary>
 ///   要素名だけを指定したコンストラクタ(翻訳機指定付き)
 /// </summary>
 public TranslatableWebControl(string name, Translatable tr) : base(name)
 {
     Translator = tr;
 }
Ejemplo n.º 13
0
            public StringBuilder GetDataHtml(Translatable page, StringBuilder sb, Record rec)
            {
                if ((recordname == null) || (recordname == ""))
                {
                    return(sb);
                }
                if (recordid < 0)
                {
                    recordid = rec.GetId(recordname);
                }
                if (style == Style.SUBINFO)
                {
                    sb.Append("<div class='subinfo'>");
                }
                else if (style == Style.OPERATION)
                {
                    sb.Append("<div class='operation'>");
                }
                switch (decoration)
                {
                case Decoration.PAREN:
                    sb.Append("(");
                    break;

                case Decoration.LTGT:
                    sb.Append("&lt;");
                    break;
                }

                string txt = rec.GetDisplayString(recordid);

                if (txt == "")
                {
                    if (strikeout == null)
                    {
                        sb.Append(txt);
                    }
                    else
                    {
                        sb.Append(strikeout);
                    }
                }
                else
                {
                    Format(page, sb, txt, rec);
                }

                switch (decoration)
                {
                case Decoration.PAREN:
                    sb.Append(")");
                    break;

                case Decoration.LTGT:
                    sb.Append("&gt;");
                    break;
                }
                if (style != Style.NORMAL)
                {
                    sb.Append("</div>");
                }
                return(sb);
            }
Ejemplo n.º 14
0
 public Class NewClass(Guid id, Translatable name, Translatable information)
 {
     var @class = new Class (id, name, information);
     members.Add (@class);
     return @class;
 }
Ejemplo n.º 15
0
 /// <summary>
 ///   翻訳機指定コンストラクタ
 /// </summary>
 public TimeSelector(Translatable tr) : base(tr)
 {
 }
Ejemplo n.º 16
0
 /// <summary>
 ///   翻訳機指定コンストラクタ
 /// </summary>
 public RadioSelector(Translatable tr) : base(tr)
 {
 }
Ejemplo n.º 17
0
 /// <summary>
 ///   コンストラクタ
 /// </summary>
 public CheckBox(string name, Translatable tr) : base(name, tr)
 {
 }
Ejemplo n.º 18
0
 /// <summary>
 ///   翻訳機指定コンストラクタ
 /// </summary>
 public DropDownSelector(Translatable tr) : base(tr)
 {
 }
Ejemplo n.º 19
0
 /// <summary>
 ///   翻訳機指定コンストラクタ
 /// </summary>
 public DateSelector(Translatable tr) : base(tr)
 {
 }
Ejemplo n.º 20
0
 /// <summary>
 ///   翻訳機指定コンストラクタ
 /// </summary>
 public TranslatableWebControl(Translatable tr) : base()
 {
     Translator = tr;
 }
Ejemplo n.º 21
0
 /// <summary>
 ///   翻訳機指定コンストラクタ
 /// </summary>
 public YesNoSelector(Translatable tr) : base(tr)
 {
 }
Ejemplo n.º 22
0
 internal TextField(Class @class, Translatable name, bool nullable)
 {
     Class = @class;
     Nullable = nullable;
     Name = name;
 }
Ejemplo n.º 23
0
 internal Class(Guid id, Translatable name, Translatable information)
 {
     Id = id;
     Name = name;
     Information = information;
 }
Ejemplo n.º 24
0
 public TextField NewTextField(Translatable name, bool nullable)
 {
     var textfield = new TextField (this, name, nullable);
     members.Add (textfield);
     return textfield;
 }
Ejemplo n.º 25
0
 /// <summary>
 ///   翻訳機指定コンストラクタ
 /// </summary>
 public CheckBox(Translatable tr) : base(tr)
 {
 }
Ejemplo n.º 26
0
 /// <summary>
 ///   コンストラクタ
 /// </summary>
 public CheckBox(string name, string text, Translatable tr) : base(name, tr)
 {
     Text = text;
 }