Exemplo n.º 1
0
        public static bool IsTranslateInstanceCanditate(QueryToken token)
        {
            if (token.Type != typeof(string))
            {
                return(false);
            }

            var pr = token.GetPropertyRoute();

            if (pr == null)
            {
                return(false);
            }

            if (TranslatedInstanceLogic.RouteType(pr) == null)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        public override void Execute()
        {
            #line 9 "..\..\Translation\Views\SyncInstance.cshtml"

            CultureInfo culture = ViewBag.Culture;

            ViewBag.Title = TranslationMessage.Synchronize0In1.NiceToString().FormatWith(Model.Type.NiceName(), culture.DisplayName);

            int totalInstances = ViewBag.TotalInstances;

            if (Model.Instances.Count < totalInstances)
            {
                ViewBag.Title = ViewBag.Title + " [{0}/{1}]".FormatWith(Model.Instances.Count, totalInstances);
            }


            #line default
            #line hidden
            WriteLiteral("\r\n\r\n");


            #line 22 "..\..\Translation\Views\SyncInstance.cshtml"
            Write(Html.ScriptsJs("~/Translation/resources/" + CultureInfo.CurrentCulture.Name + ".js"));


            #line default
            #line hidden
            WriteLiteral("\r\n");


            #line 23 "..\..\Translation\Views\SyncInstance.cshtml"
            Write(Html.ScriptCss("~/Translation/Content/Translation.css"));


            #line default
            #line hidden
            WriteLiteral("\r\n\r\n");


            #line 25 "..\..\Translation\Views\SyncInstance.cshtml"
            if (Model.Instances.IsEmpty())
            {
            #line default
            #line hidden
                WriteLiteral("    <h2>");


            #line 27 "..\..\Translation\Views\SyncInstance.cshtml"
                Write(TranslationMessage._0AlreadySynchronized.NiceToString().FormatWith(@Model.Type.NiceName()));


            #line default
            #line hidden
                WriteLiteral("</h2>   \r\n");


            #line 28 "..\..\Translation\Views\SyncInstance.cshtml"
            }
            else
            {
            #line default
            #line hidden
                WriteLiteral("    <h2>");


            #line 31 "..\..\Translation\Views\SyncInstance.cshtml"
                Write(ViewBag.Title);


            #line default
            #line hidden
                WriteLiteral("</h2>\r\n");


            #line 32 "..\..\Translation\Views\SyncInstance.cshtml"

                using (Html.BeginForm((TranslatedInstanceController c) => c.SaveSync(Signum.Engine.Basics.TypeLogic.GetCleanName(Model.Type), culture.Name)))
                {
            #line default
            #line hidden
                    WriteLiteral("    <table");

                    WriteLiteral(" id=\"results\"");

                    WriteLiteral(" style=\"width: 100%; margin: 0px\"");

                    WriteLiteral(" class=\"st\"");

                    WriteLiteral("        \r\n        data-feedback=\"");


            #line 36 "..\..\Translation\Views\SyncInstance.cshtml"
                    Write(Url.Action("Feedback", "Translation"));


            #line default
            #line hidden
                    WriteLiteral("\"");

                    WriteLiteral(" \r\n        data-culture=\"");


            #line 37 "..\..\Translation\Views\SyncInstance.cshtml"
                    Write(culture.Name);


            #line default
            #line hidden
                    WriteLiteral("\"");

                    WriteLiteral(">\r\n");


            #line 38 "..\..\Translation\Views\SyncInstance.cshtml"


            #line default
            #line hidden

            #line 38 "..\..\Translation\Views\SyncInstance.cshtml"
                    foreach (InstanceChanges instance in Model.Instances)
                    {
            #line default
            #line hidden
                        WriteLiteral("            <thead>\r\n                <tr>\r\n                    <th");

                        WriteLiteral(" class=\"leftCell\"");

                        WriteLiteral(">");


            #line 42 "..\..\Translation\Views\SyncInstance.cshtml"
                        Write(TranslationMessage.Instance.NiceToString());


            #line default
            #line hidden
                        WriteLiteral("</th>\r\n                    <th");

                        WriteLiteral(" class=\"titleCell\"");

                        WriteLiteral(">");


            #line 43 "..\..\Translation\Views\SyncInstance.cshtml"
                        Write(Html.Href(Navigator.NavigateRoute(instance.Instance), instance.Instance.ToString()));


            #line default
            #line hidden
                        WriteLiteral("</th>\r\n                </tr>\r\n            </thead>\r\n");


            #line 46 "..\..\Translation\Views\SyncInstance.cshtml"

                        foreach (var route in instance.RouteConflicts.OrderBy(a => a.Key.ToString()))
                        {
                            var propertyString = route.Key.ToString();


            #line default
            #line hidden
                            WriteLiteral("            <tr>\r\n                <th");

                            WriteLiteral(" class=\"leftCell\"");

                            WriteLiteral(">");


            #line 51 "..\..\Translation\Views\SyncInstance.cshtml"
                            Write(TranslationMessage.Property.NiceToString());


            #line default
            #line hidden
                            WriteLiteral("\r\n                </th>\r\n                <th>");


            #line 53 "..\..\Translation\Views\SyncInstance.cshtml"
                            Write(propertyString);


            #line default
            #line hidden
                            WriteLiteral("</th>\r\n            </tr>\r\n");


            #line 55 "..\..\Translation\Views\SyncInstance.cshtml"
                            foreach (var mc in route.Value)
                            {
            #line default
            #line hidden
                                WriteLiteral("            <tr>\r\n                <td");

                                WriteLiteral(" class=\"leftCell\"");

                                WriteLiteral(">");


            #line 58 "..\..\Translation\Views\SyncInstance.cshtml"
                                Write(mc.Key.Name);


            #line default
            #line hidden
                                WriteLiteral("</td>\r\n                <td");

                                WriteLiteral(" class=\"monospaceCell\"");

                                WriteLiteral(">\r\n");


            #line 60 "..\..\Translation\Views\SyncInstance.cshtml"


            #line default
            #line hidden

            #line 60 "..\..\Translation\Views\SyncInstance.cshtml"
                                if (mc.Key.Equals(TranslatedInstanceLogic.DefaultCulture))
                                {
                                    string originalName = TranslatedInstanceLogic.DefaultCulture.Name + "#" + instance.Instance.Key() + "#" + propertyString;


            #line default
            #line hidden
                                    WriteLiteral("                        <textarea");

                                    WriteAttribute("name", Tuple.Create(" name=\"", 2545), Tuple.Create("\"", 2565)

            #line 63 "..\..\Translation\Views\SyncInstance.cshtml"
                                                   , Tuple.Create(Tuple.Create("", 2552), Tuple.Create <System.Object, System.Int32>(originalName

            #line default
            #line hidden
                                                                                                                                     , 2552), false)
                                                   );

                                    WriteLiteral(" style=\"display:none\"");

                                    WriteLiteral(" >");


            #line 63 "..\..\Translation\Views\SyncInstance.cshtml"
                                    Write(mc.Value.Original);


            #line default
            #line hidden
                                    WriteLiteral("</textarea>\r\n");


            #line 64 "..\..\Translation\Views\SyncInstance.cshtml"
                                }


            #line default
            #line hidden
                                WriteLiteral("\r\n");


            #line 66 "..\..\Translation\Views\SyncInstance.cshtml"


            #line default
            #line hidden

            #line 66 "..\..\Translation\Views\SyncInstance.cshtml"
                                if (mc.Value.OldOriginal != null)
                                {
            #line default
            #line hidden
                                    WriteLiteral("                        <pre>");


            #line 68 "..\..\Translation\Views\SyncInstance.cshtml"
                                    Write(TranslationClient.Diff(mc.Value.OldOriginal, mc.Value.Original));


            #line default
            #line hidden
                                    WriteLiteral("</pre>\r\n");


            #line 69 "..\..\Translation\Views\SyncInstance.cshtml"
                                }
                                else if (TranslatedInstanceLogic.RouteType(route.Key.Route).Value == TranslateableRouteType.Html)
                                {
            #line default
            #line hidden
                                    WriteLiteral("                        <pre>");


            #line 72 "..\..\Translation\Views\SyncInstance.cshtml"
                                    Write(mc.Value.Original);


            #line default
            #line hidden
                                    WriteLiteral("</pre>\r\n");


            #line 73 "..\..\Translation\Views\SyncInstance.cshtml"
                                }
                                else
                                {
            #line default
            #line hidden
                                    WriteLiteral("                        <pre>");


            #line 76 "..\..\Translation\Views\SyncInstance.cshtml"
                                    Write(mc.Value.Original);


            #line default
            #line hidden
                                    WriteLiteral("</pre>   \r\n");


            #line 77 "..\..\Translation\Views\SyncInstance.cshtml"
                                }


            #line default
            #line hidden
                                WriteLiteral("                </td>\r\n            </tr>\r\n");


            #line 80 "..\..\Translation\Views\SyncInstance.cshtml"
                            }


            #line default
            #line hidden
                            WriteLiteral("            <tr>\r\n                <td");

                            WriteLiteral(" class=\"leftCell\"");

                            WriteLiteral(">");


            #line 82 "..\..\Translation\Views\SyncInstance.cshtml"
                            Write(culture.Name);


            #line default
            #line hidden
                            WriteLiteral("</td>\r\n                <td");

                            WriteLiteral(" class=\"monospaceCell\"");

                            WriteLiteral(">\r\n");


            #line 84 "..\..\Translation\Views\SyncInstance.cshtml"


            #line default
            #line hidden

            #line 84 "..\..\Translation\Views\SyncInstance.cshtml"

                            var translations = route.Value.Where(kvp => kvp.Value.OldTranslation != null)
                                               .Select(kvp => new SelectListItem {
                                Text = "old translation - " + kvp.Value.OldTranslation, Value = kvp.Value.OldTranslation
                            })
                                               .Concat(route.Value.Select(kvp => new SelectListItem {
                                Text = "from " + kvp.Key + " - " + kvp.Value.AutomaticTranslation, Value = kvp.Value.AutomaticTranslation
                            }))
                                               .ToList();

                            string elementName = culture.Name + "#" + instance.Instance.Key() + "#" + propertyString;
                            if (translations.Count() == 1)
                            {
            #line default
            #line hidden
                                WriteLiteral("                        <textarea");

                                WriteAttribute("name", Tuple.Create(" name=\"", 4082), Tuple.Create("\"", 4112)

            #line 93 "..\..\Translation\Views\SyncInstance.cshtml"
                                               , Tuple.Create(Tuple.Create("", 4089), Tuple.Create <System.Object, System.Int32>(elementName

            #line default
            #line hidden
                                                                                                                                 , 4089), false)
                                               , Tuple.Create(Tuple.Create("", 4103), Tuple.Create("_original", 4103), true)
                                               );

                                WriteLiteral(" style=\"display:none\"");

                                WriteLiteral(" disabled=\"disabled\"");

                                WriteLiteral(">");


            #line 93 "..\..\Translation\Views\SyncInstance.cshtml"
                                Write(translations.First().Value);


            #line default
            #line hidden
                                WriteLiteral("</textarea>\r\n");

                                WriteLiteral("                        <textarea");

                                WriteAttribute("name", Tuple.Create(" name=\"", 4228), Tuple.Create("\"", 4247)

            #line 94 "..\..\Translation\Views\SyncInstance.cshtml"
                                               , Tuple.Create(Tuple.Create("", 4235), Tuple.Create <System.Object, System.Int32>(elementName

            #line default
            #line hidden
                                                                                                                                 , 4235), false)
                                               );

                                WriteLiteral(" style=\"width:90%\"");

                                WriteLiteral(" data-original=\"");


            #line 94 "..\..\Translation\Views\SyncInstance.cshtml"
                                Write(translations.First().Value);


            #line default
            #line hidden
                                WriteLiteral("\"");

                                WriteLiteral(">");


            #line 94 "..\..\Translation\Views\SyncInstance.cshtml"
                                Write(translations.First().Value);


            #line default
            #line hidden
                                WriteLiteral("</textarea>\r\n");


            #line 95 "..\..\Translation\Views\SyncInstance.cshtml"
                                if (TranslationClient.Translator is ITranslatorWithFeedback)
                                {
            #line default
            #line hidden
                                    WriteLiteral("                        <button");

                                    WriteLiteral(" class=\"rememberChange\"");

                                    WriteLiteral(">");


            #line 97 "..\..\Translation\Views\SyncInstance.cshtml"
                                    Write(TranslationJavascriptMessage.RememberChange.NiceToString());


            #line default
            #line hidden
                                    WriteLiteral("</button>\r\n");


            #line 98 "..\..\Translation\Views\SyncInstance.cshtml"
                                }
                            }
                            else
                            {
                                if (translations.Count() > 1 && translations.Select(a => a.Value).Distinct().Count() == 1)
                                {
                                    translations.First().Selected = true;
                                    translations.Insert(0, new SelectListItem {
                                        Value = "", Text = "-"
                                    });
                                }
                                else
                                {
                                    translations.Insert(0, new SelectListItem {
                                        Value = "", Text = "-", Selected = true
                                    });
                                }



            #line default
            #line hidden

            #line 112 "..\..\Translation\Views\SyncInstance.cshtml"
                                Write(Html.SafeDropDownList(elementName, translations));


            #line default
            #line hidden

            #line 112 "..\..\Translation\Views\SyncInstance.cshtml"
                                ;


            #line default
            #line hidden
                                WriteLiteral("                        <a");

                                WriteLiteral(" href=\"#\"");

                                WriteLiteral(" class=\"edit\"");

                                WriteLiteral(">");


            #line 113 "..\..\Translation\Views\SyncInstance.cshtml"
                                Write(TranslationMessage.Edit.NiceToString());


            #line default
            #line hidden
                                WriteLiteral("</a>\r\n");


            #line 114 "..\..\Translation\Views\SyncInstance.cshtml"
                            }


            #line default
            #line hidden
                            WriteLiteral("\r\n                </td>\r\n            </tr>\r\n");


            #line 118 "..\..\Translation\Views\SyncInstance.cshtml"
                        }
                    }


            #line default
            #line hidden
                    WriteLiteral("    </table>\r\n");

                    WriteLiteral("    <input");

                    WriteLiteral(" type=\"submit\"");

                    WriteAttribute("value", Tuple.Create(" value=\"", 5506), Tuple.Create("\"", 5553)

            #line 121 "..\..\Translation\Views\SyncInstance.cshtml"
                                   , Tuple.Create(Tuple.Create("", 5514), Tuple.Create <System.Object, System.Int32>(TranslationMessage.Save.NiceToString()

            #line default
            #line hidden
                                                                                                                     , 5514), false)
                                   );

                    WriteLiteral(" />\r\n");


            #line 122 "..\..\Translation\Views\SyncInstance.cshtml"
                }
            }


            #line default
            #line hidden
            WriteLiteral("\r\n<script>\r\n    $(function () {\r\n");

            WriteLiteral("        ");


            #line 127 "..\..\Translation\Views\SyncInstance.cshtml"
            Write(TranslationClient.Module["editAndRemember"](TranslationClient.Translator is ITranslatorWithFeedback));


            #line default
            #line hidden
            WriteLiteral("\r\n");

            WriteLiteral("        ");


            #line 128 "..\..\Translation\Views\SyncInstance.cshtml"
            Write(TranslationClient.Module["fixTextAreas"]());


            #line default
            #line hidden
            WriteLiteral("\r\n    });\r\n</script>\r\n");
        }
Exemplo n.º 3
0
        public override void Execute()
        {
            #line 8 "..\..\Translation\Views\ViewInstance.cshtml"

            CultureInfo culture = ViewBag.Culture;
            Type        type    = ViewBag.Type;

            ViewBag.Title = TranslationMessage.View0In1.NiceToString().FormatWith(type.NiceName(), culture == null ? TranslationMessage.AllLanguages.NiceToString() : culture.DisplayName);

            Dictionary <LocalizedInstanceKey, string> master = ViewBag.Master;

            var cultures = TranslationLogic.CurrentCultureInfos(TranslatedInstanceLogic.DefaultCulture);

            Func <CultureInfo, bool> editCulture = c => culture == null || culture.Name == c.Name;

            var filter = (string)ViewBag.Filter;

            var all = string.IsNullOrEmpty(filter);

            Func <LocalizedInstanceKey, bool> filtered = li => all ||
                                                         li.RowId.ToString() == filter ||
                                                         li.Instance.Id.ToString() == filter ||
                                                         li.Route.PropertyString().Contains(filter, StringComparison.InvariantCultureIgnoreCase) ||
                                                         master.GetOrThrow(li).Contains(filter, StringComparison.InvariantCultureIgnoreCase) ||
                                                         cultures.Any(ci => (Model.TryGetC(ci)?.TryGetC(li)?.TranslatedText ?? "").Contains(filter, StringComparison.InvariantCultureIgnoreCase));


            #line default
            #line hidden
            WriteLiteral("\r\n");


            #line 31 "..\..\Translation\Views\ViewInstance.cshtml"
            Write(Html.ScriptCss("~/Translation/Content/Translation.css"));


            #line default
            #line hidden
            WriteLiteral("\r\n\r\n\r\n\r\n<h2>");


            #line 35 "..\..\Translation\Views\ViewInstance.cshtml"
            Write(ViewBag.Title);


            #line default
            #line hidden
            WriteLiteral("</h2>\r\n\r\n<div>\r\n");


            #line 38 "..\..\Translation\Views\ViewInstance.cshtml"


            #line default
            #line hidden

            #line 38 "..\..\Translation\Views\ViewInstance.cshtml"
            using (Html.BeginForm("View", "TranslatedInstance", FormMethod.Get))
            {
            #line default
            #line hidden

            #line 40 "..\..\Translation\Views\ViewInstance.cshtml"
                Write(Html.Hidden("type"));


            #line default
            #line hidden

            #line 40 "..\..\Translation\Views\ViewInstance.cshtml"



            #line default
            #line hidden

            #line 41 "..\..\Translation\Views\ViewInstance.cshtml"
                Write(Html.Hidden("culture"));


            #line default
            #line hidden

            #line 41 "..\..\Translation\Views\ViewInstance.cshtml"



            #line default
            #line hidden

            #line 42 "..\..\Translation\Views\ViewInstance.cshtml"
                Write(Html.TextBox("filter", filter));


            #line default
            #line hidden

            #line 42 "..\..\Translation\Views\ViewInstance.cshtml"
                ;



            #line default
            #line hidden
                WriteLiteral("        <input");

                WriteLiteral(" type=\"hidden\"");

                WriteLiteral(" name=\"searchPressed\"");

                WriteLiteral(" value=\"true\"");

                WriteLiteral(" />\r\n");

                WriteLiteral("        <input");

                WriteLiteral(" type=\"submit\"");

                WriteAttribute("value", Tuple.Create(" value=\"", 1786), Tuple.Create("\"", 1835)

            #line 45 "..\..\Translation\Views\ViewInstance.cshtml"
                               , Tuple.Create(Tuple.Create("", 1794), Tuple.Create <System.Object, System.Int32>(TranslationMessage.Search.NiceToString()

            #line default
            #line hidden
                                                                                                                 , 1794), false)
                               );

                WriteLiteral(" />\r\n");


            #line 46 "..\..\Translation\Views\ViewInstance.cshtml"
            }


            #line default
            #line hidden
            WriteLiteral("</div>\r\n\r\n");


            #line 49 "..\..\Translation\Views\ViewInstance.cshtml"
            if (Model == null)
            {
            #line default
            #line hidden
                WriteLiteral("    <em>");


            #line 51 "..\..\Translation\Views\ViewInstance.cshtml"
                Write(TranslationMessage.PressSearchForResults.NiceToString());


            #line default
            #line hidden
                WriteLiteral("</em>\r\n");


            #line 52 "..\..\Translation\Views\ViewInstance.cshtml"
            }
            else if (Model.IsEmpty())
            {
            #line default
            #line hidden
                WriteLiteral("    <strong>");


            #line 55 "..\..\Translation\Views\ViewInstance.cshtml"
                Write(TranslationMessage.NoResultsFound.NiceToString());


            #line default
            #line hidden
                WriteLiteral("</strong>\r\n");


            #line 56 "..\..\Translation\Views\ViewInstance.cshtml"
            }
            else
            {
                using (Html.BeginForm((TranslatedInstanceController c) => c.SaveView(Signum.Engine.Basics.TypeLogic.GetCleanName(type), culture == null ? null : culture.Name, filter)))
                {
            #line default
            #line hidden
                    WriteLiteral("        <table");

                    WriteLiteral(" id=\"results\"");

                    WriteLiteral(" style=\"width: 100%; margin: 0px\"");

                    WriteLiteral(" class=\"st\"");

                    WriteLiteral(">\r\n");


            #line 62 "..\..\Translation\Views\ViewInstance.cshtml"


            #line default
            #line hidden

            #line 62 "..\..\Translation\Views\ViewInstance.cshtml"
                    foreach (var instance in master.Keys.Where(li => master.GetOrThrow(li).HasText()).Where(filtered).GroupBy(a => a.Instance).OrderBy(a => a.Key.Id))
                    {
            #line default
            #line hidden
                        WriteLiteral("                <thead>\r\n                    <tr>\r\n                        <th");

                        WriteLiteral(" class=\"leftCell\"");

                        WriteLiteral(">");


            #line 66 "..\..\Translation\Views\ViewInstance.cshtml"
                        Write(TranslationMessage.Instance.NiceToString());


            #line default
            #line hidden
                        WriteLiteral("</th>\r\n                        <th");

                        WriteLiteral(" class=\"titleCell\"");

                        WriteLiteral(">");


            #line 67 "..\..\Translation\Views\ViewInstance.cshtml"
                        Write(Html.Href(Navigator.NavigateRoute(instance.Key), instance.Key.ToString()));


            #line default
            #line hidden
                        WriteLiteral("</th>\r\n                    </tr>\r\n                </thead>\r\n");


            #line 70 "..\..\Translation\Views\ViewInstance.cshtml"

                        foreach (LocalizedInstanceKey key in instance.OrderBy(a => a.Route.ToString()))
                        {
                            var propertyString = key.Route.PropertyString().Replace("/", "[" + key.RowId + "].");


            #line default
            #line hidden
                            WriteLiteral("                    <tr>\r\n                        <th");

                            WriteLiteral(" class=\"leftCell\"");

                            WriteLiteral(">\r\n");

                            WriteLiteral("                            ");


            #line 76 "..\..\Translation\Views\ViewInstance.cshtml"
                            Write(TranslationMessage.Property.NiceToString());


            #line default
            #line hidden
                            WriteLiteral("\r\n                    </th>\r\n                    <th>");


            #line 78 "..\..\Translation\Views\ViewInstance.cshtml"
                            Write(propertyString);


            #line default
            #line hidden
                            WriteLiteral("</th>\r\n                </tr>\r\n");


            #line 80 "..\..\Translation\Views\ViewInstance.cshtml"

                            foreach (var ci in cultures)
                            {
                                var formName = ci.Name + "#" + key.Instance.Key() + "#" + propertyString;

                                if (ci.Name == TranslatedInstanceLogic.DefaultCulture.Name)
                                {
            #line default
            #line hidden
                                    WriteLiteral("                            <tr>\r\n                                <td");

                                    WriteLiteral(" class=\"leftCell\"");

                                    WriteLiteral("><em>");


            #line 88 "..\..\Translation\Views\ViewInstance.cshtml"
                                    Write(TranslatedInstanceLogic.DefaultCulture);


            #line default
            #line hidden
                                    WriteLiteral("</em></td>\r\n                                <td");

                                    WriteLiteral(" class=\"monospaceCell\"");

                                    WriteLiteral(">\r\n");


            #line 90 "..\..\Translation\Views\ViewInstance.cshtml"


            #line default
            #line hidden

            #line 90 "..\..\Translation\Views\ViewInstance.cshtml"
                                    if (TranslatedInstanceLogic.RouteType(key.Route).Value == TranslateableRouteType.Html)
                                    {
            #line default
            #line hidden
                                        WriteLiteral("                                        <pre>");


            #line 92 "..\..\Translation\Views\ViewInstance.cshtml"
                                        Write(master[key]);


            #line default
            #line hidden
                                        WriteLiteral("</pre>\r\n");


            #line 93 "..\..\Translation\Views\ViewInstance.cshtml"
                                    }
                                    else
                                    {
            #line default
            #line hidden

            #line 96 "..\..\Translation\Views\ViewInstance.cshtml"
                                        Write(master[key]);


            #line default
            #line hidden

            #line 96 "..\..\Translation\Views\ViewInstance.cshtml"
                                    }


            #line default
            #line hidden
                                    WriteLiteral("                                    ");


            #line 98 "..\..\Translation\Views\ViewInstance.cshtml"
                                    Write(Html.TextArea(formName, master[key], new { style = "display:none" }));


            #line default
            #line hidden
                                    WriteLiteral("\r\n                                </td>\r\n                            </tr>\r\n");


            #line 101 "..\..\Translation\Views\ViewInstance.cshtml"
                                }
                                else
                                {
                                    TranslatedInstanceEntity trans = Model.TryGetC(ci)?.TryGetC(key);

                                    if (trans != null && editCulture(ci))
                                    {
            #line default
            #line hidden
                                        WriteLiteral("                                <tr>\r\n                                    <td");

                                        WriteLiteral(" class=\"leftCell\"");

                                        WriteLiteral(">");


            #line 109 "..\..\Translation\Views\ViewInstance.cshtml"
                                        Write(ci.Name);


            #line default
            #line hidden
                                        WriteLiteral(" Diff</td>\r\n                                    <td");

                                        WriteLiteral(" class=\"monospaceCell\"");

                                        WriteLiteral(">\r\n                                        <pre>");


            #line 111 "..\..\Translation\Views\ViewInstance.cshtml"
                                        Write(Signum.Web.Translation.TranslationClient.Diff(trans.OriginalText, trans.TranslatedText));


            #line default
            #line hidden
                                        WriteLiteral("</pre>\r\n                                    </td>\r\n                              " +
                                                     "  </tr>\r\n");


            #line 114 "..\..\Translation\Views\ViewInstance.cshtml"
                                    }


                                    if (trans != null || editCulture(ci))
                                    {
            #line default
            #line hidden
                                        WriteLiteral("                                <tr>\r\n                                    <td");

                                        WriteLiteral(" class=\"leftCell\"");

                                        WriteLiteral(">");


            #line 121 "..\..\Translation\Views\ViewInstance.cshtml"
                                        Write(ci.Name);


            #line default
            #line hidden
                                        WriteLiteral("</td>\r\n                                    <td");

                                        WriteLiteral(" class=\"monospaceCell\"");

                                        WriteLiteral(">\r\n");


            #line 123 "..\..\Translation\Views\ViewInstance.cshtml"


            #line default
            #line hidden

            #line 123 "..\..\Translation\Views\ViewInstance.cshtml"
                                        if (editCulture(ci))
                                        {
            #line default
            #line hidden

            #line 125 "..\..\Translation\Views\ViewInstance.cshtml"
                                            Write(Html.TextArea(formName, trans?.TranslatedText, new { style = "width:90%;" }));


            #line default
            #line hidden

            #line 125 "..\..\Translation\Views\ViewInstance.cshtml"
                                        }
                                        else if (TranslatedInstanceLogic.RouteType(key.Route).Value == TranslateableRouteType.Html)
                                        {
            #line default
            #line hidden
                                            WriteLiteral("                                            <pre>");


            #line 129 "..\..\Translation\Views\ViewInstance.cshtml"
                                            Write(trans.TranslatedText);


            #line default
            #line hidden
                                            WriteLiteral("</pre>\r\n");


            #line 130 "..\..\Translation\Views\ViewInstance.cshtml"
                                        }
                                        else
                                        {
            #line default
            #line hidden

            #line 133 "..\..\Translation\Views\ViewInstance.cshtml"
                                            Write(trans.TranslatedText);


            #line default
            #line hidden

            #line 133 "..\..\Translation\Views\ViewInstance.cshtml"
                                        }


            #line default
            #line hidden
                                        WriteLiteral("                                    </td>\r\n                                </tr>\r" +
                                                     "\n");


            #line 137 "..\..\Translation\Views\ViewInstance.cshtml"
                                    }
                                }
                            }
                        }
                    }


            #line default
            #line hidden
                    WriteLiteral("        </table>\r\n");

                    WriteLiteral("        <input");

                    WriteLiteral(" type=\"submit\"");

                    WriteAttribute("value", Tuple.Create(" value=\"", 6410), Tuple.Create("\"", 6457)

            #line 144 "..\..\Translation\Views\ViewInstance.cshtml"
                                   , Tuple.Create(Tuple.Create("", 6418), Tuple.Create <System.Object, System.Int32>(TranslationMessage.Save.NiceToString()

            #line default
            #line hidden
                                                                                                                     , 6418), false)
                                   );

                    WriteLiteral(" />\r\n");


            #line 145 "..\..\Translation\Views\ViewInstance.cshtml"
                }
            }


            #line default
            #line hidden
            WriteLiteral("\r\n\r\n<script>\r\n    $(function () {\r\n");

            WriteLiteral("        ");


            #line 151 "..\..\Translation\Views\ViewInstance.cshtml"
            Write(Signum.Web.Translation.TranslationClient.Module["fixTextAreas"]());


            #line default
            #line hidden
            WriteLiteral("\r\n    });\r\n</script>\r\n");
        }
Exemplo n.º 4
0
    public static void Start(IApplicationBuilder app, params ITranslator[] translators)
    {
        Translators = translators;

        SignumControllerFactory.RegisterArea(MethodInfo.GetCurrentMethod());

        ReflectionServer.RegisterLike(typeof(TranslationMessage), () => TranslationPermission.TranslateCode.IsAuthorized() || TranslationPermission.TranslateInstances.IsAuthorized());

        ReflectionServer.PropertyRouteExtension += (mi, pr) =>
        {
            var type = TranslatedInstanceLogic.TranslateableRoutes.TryGetC(pr.RootType)?.TryGetS(pr);
            if (type != null)
            {
                mi.Extension.Add("translatable", true);
            }
            return(mi);
        };

        var pairs = TranslatedInstanceLogic.TranslateableRoutes.Values.SelectMany(a => a.Keys)
                    .Select(pr => (type: pr.Parent !.Type, prop: pr.PropertyInfo !))
                    .Distinct()
                    .ToList();

        foreach (var(type, prop) in pairs)
        {
            var converters = SignumServer.WebEntityJsonConverterFactory.GetPropertyConverters(type);

            converters.Add(prop.Name.FirstLower() + "_translated", new PropertyConverter()
            {
                AvoidValidate          = true,
                CustomReadJsonProperty = (ref Utf8JsonReader reader, ReadJsonPropertyContext ctx) =>
                {
                    var pr = ctx.ParentPropertyRoute.Add(prop);

                    if (TranslatedInstanceLogic.RouteType(pr) == null)
                    {
                        return;
                    }

                    var discard = reader.GetString();
                },
                CustomWriteJsonProperty = (Utf8JsonWriter writer, WriteJsonPropertyContext ctx) =>
                {
                    var pr = ctx.ParentPropertyRoute.Add(prop);

                    if (TranslatedInstanceLogic.RouteType(pr) == null)
                    {
                        return;
                    }

                    var hastMList = pr.GetMListItemsRoute() != null;

                    var entity = ctx.Entity as Entity ?? (Entity?)EntityJsonContext.FindCurrentRootEntity();

                    var rowId = hastMList ? EntityJsonContext.FindCurrentRowId() : null;

                    writer.WritePropertyName(ctx.LowerCaseName);

                    var value = entity == null || entity.IsNew || hastMList && rowId == null /*UserQuery apply changes*/ ? null :
                                TranslatedInstanceLogic.TranslatedField(entity.ToLite(), pr, rowId, null !);

                    writer.WriteStringValue(value);
                }
            });