Пример #1
0
        public async Task <IActionResult> ToMongo()
        {
            var package = _translateService.GetPackage();

            List <TranslateString> strings = await _store.GetStrings("robin");

            foreach (var res in package.GetTextResources())
            {
                Console.WriteLine(res);
                var en = res.GetStrings(false);
                var tr = res.GetStrings(true);

                for (int i = 0; i < en.Length; i++)
                {
                    var translate = tr[i] == en[i] ? null : tr[i];

                    var str = strings.Find(s => s.Res == res.ToString() && s.Index == i);

                    if (str == null)
                    {
                        await _store.AddString("robin", res.ToString(), i, en[i], translate);
                    }
                    else if (str.Tr != translate)
                    {
                        await _store.Update(str, s => s.Tr, translate);
                    }
                }
            }

            return(Ok());
        }