public IActionResult Item(string id, [FromBody] JsonPatchDocument <LangItem> langItemPatch) { try { if (Guid.TryParse(id, out Guid parsedId)) { //var userId = User.FindFirstValue("sub"); LanguageItem languageItem = _unitOfWork.LanguageItems.Get(parsedId); LangItem langItem = _mapper.Map <LangItem>(languageItem); langItemPatch.ApplyTo(langItem); _mapper.Map(langItem, languageItem); _unitOfWork.Complete(); return(CreatedAtRoute("Item", new { id = _mapper.Map <LangItem>(languageItem).Id }, _mapper.Map <LangItem>(languageItem))); } } catch (Exception e) { string message = e.Message; } return(BadRequest()); }
void DoLoad() { var xlsFile = EditorUtility.OpenFilePanel("load excel file", "", "xls;*.xlsx;"); if (xlsFile.Length != 0) { m_Workbook = ExcelHelper.Load(xlsFile); //第一张表 ISheet sheet = m_Workbook.GetSheetAt(0); m_Schema = EDSchemaReader.ReadSchema(sheet); //第一列为Key,其它为语言 List <LangItem> list = new List <LangItem>(); for (int i = 1; i < m_Schema.fields.Count; ++i) { LangItem item = new LangItem(); item.name = m_Schema.fields[i].name; item.convertable = true; list.Add(item); } m_LangItems = list.ToArray(); } }
private static void AddToAll(LangItem item) { if (all == null) { all = new System.Collections.Generic.List<LangItem> (); } all.Add (item); }
private static void RemoveFromAll(LangItem item) { if (all != null) { all.Remove(item); } }
public string I(string key, params object[] args) { string resStr = key; if (!string.IsNullOrEmpty(resStr)) { LangItem litem = null; if (!lanStrs.TryGetValue(key, out litem)) { //查找翻译失败 saveUnTransStr(key); } else if (!string.IsNullOrEmpty(litem.Text)) { resStr = litem.Text; } } if (args.Length > 0) { return(string.Format(resStr, args)); } else { return(resStr); } }
private static void AddToAll(LangItem item) { if (all == null) { all = new System.Collections.Generic.List <LangItem> (); } all.Add(item); }
public static void ChangeLang(int lang) { //重新加载数据 Lang = lang; //GameData.LoadData(); //if (GameData.save != null) // GameData.save.ChangeLanguage(lang); LangItem.ChangeLang(); //MainCityCtrl.Ins.ChangeLang(); //MainTownCtrl.Ins.ChangeLang(); //BuildListCtrl.Ins.ChangeLang(); }
public static void ChangeLang(this Text txt) { LangItem ctrl = txt.GetComponent <LangItem>(); if (ctrl != null) { string text = ctrl.GetLangStr(); //如果找不到字串,那么不改变. if (text != null) { txt.text = text; } } }
/// <summary> /// get the string value by id /// </summary> /// <param name="stringID">string id</param> /// <param name="category">file name</param> /// <returns></returns> public static string GetString(string stringID, string category) { string langCult = GetLangCult(); string[] langCultTemp = langCult.Split('-'); string language = langCultTemp.Length > 0 ? langCultTemp[0] : string.Empty; string area = langCultTemp.Length > 1 ? langCultTemp[1] : string.Empty; XElement langXml = LangItem.Get(language, area, category).Value; XElement result = langXml.XPathSelectElement("String[@id='" + stringID + "']"); if (result != null) { return(result.Value); } return(string.Empty); }
private async Task <bool> CreateOrUpdateLanguageItemAsync(LangItem langItem, string apiAccessToken) { if (langItem != null) { if (langItem.Id != Guid.Empty) { var response = await _apiHelper.MakeAPICallAsync(apiAccessToken, HttpMethod.Get, APITypes.FOUNDATION, $"Language/Item/{langItem.Id}"); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var foundItem = response.ContentAsType <LangItem>(); if (foundItem != null) { if (!await _modelHelper.ProcessPatch(foundItem, langItem, foundItem.Id, apiAccessToken, APITypes.FOUNDATION, "Language/Item")) { return(false); } } } } else { HttpContent contentPost = new StringContent(JsonConvert.SerializeObject(langItem), Encoding.UTF8, "application/json"); try { var response = await _apiHelper.MakeAPICallAsync(apiAccessToken, HttpMethod.Post, APITypes.FOUNDATION, $"Language/Item", contentPost); if (response.StatusCode != System.Net.HttpStatusCode.Created) { return(false); } } catch (Exception ex) { var responseString = $"Error calling API: {ex.Message}"; return(false); } } } return(true); }
public IActionResult Item([FromBody] LangItem langItem) { try { if (langItem.Id == Guid.Empty) { //var userId = User.FindFirstValue("sub"); var languageItem = _mapper.Map <LanguageItem>(langItem); _unitOfWork.LanguageItems.Add(languageItem); _unitOfWork.Complete(); return(Created(new Uri($"{Request.Path}/Item/{languageItem.Id}", UriKind.Relative), _mapper.Map <LangItem>(languageItem))); } } catch (Exception e) { string message = e.Message; } return(BadRequest()); }
//游戏接口 public void GameStart() { LangItem.ChangeLang(); OnGameStart(); return; }
private async Task <bool> GeneratePageConstructionModel() { LangItem dummyLangItem = new LangItem() { Id = Guid.Empty, LanguageHeaderId = Guid.Parse("11111111-1111-1111-1111-111111111111"), LanguageCodeId = "EN" }; LanguageHeaderModel dummyLanguageHeaderModel = new LanguageHeaderModel() { langHead = new LangHead(), StatusList = StatusList, LanguageCodeSelectList = LanguageCodeSelectList }; dummyLanguageHeaderModel.langHead.LanguageItems.Add(dummyLangItem); var langListHTML = await _renderer.RenderPartialToStringAsync("_LangItemTable", dummyLanguageHeaderModel); langListHTML = langListHTML.Replace("\n", "").Replace("\r", "").Replace("\t", "").ToString(); var langItemListTableHTML = _renderer.GetStringBetween(langListHTML, "<!--LangItemTableRowsStart-->", "<!--LangItemTableRowsEnd-->"); List <string> langItemListRows = langItemListTableHTML.TrimStart().TrimEnd().Replace("<td>", "").Split("</td>").ToList(); for (int i = langItemListRows.Count - 1; i >= 0; i--) { var eol = ","; langItemListRows[i] = langItemListRows[i].TrimStart().TrimEnd(); if (string.IsNullOrWhiteSpace(langItemListRows[i])) { langItemListRows.RemoveAt(i); continue; } if (i == langItemListRows.Count - 1) { eol = ""; } langItemListRows[i] = langItemListRows[i].Replace("langHead_LanguageItems_0__", "langHead_LanguageItems_' + rowCount + '__"); langItemListRows[i] = langItemListRows[i].Replace("langHead.LanguageItems[0]", "langHead.LanguageItems[' + rowCount + ']"); langItemListRows[i] = langItemListRows[i].Replace("11111111-1111-1111-1111-111111111111", "' + headerId + '"); langItemListRows[i] = $"'{langItemListRows[i]}'{eol}"; } langItemRows = langItemListRows.ToArray(); languageHeaderModel = new LanguageHeaderModel() { langHead = this.langHead, StatusList = this.StatusList, LanguageCodeSelectList = this.LanguageCodeSelectList, langQueryList = this.langQueryList }; return(true); }
private static void RemoveFromAll(LangItem item) { if (all != null) { all.Remove (item); } }
get => Enum.TryParse(UserConfigFile.GetValue(LangItem, nameof(LengthUnit)), out LengthUnit lengthUnit)