Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Alexander 3 posts 62 karma points
    Dec 29, 2014 @ 15:41
    Alexander
    0

    Working with resource files for multilingual sites

    Good evening.

    A following question:

    - When the method for Ajax request, it does not automatically detect the language of the site and choose the required resource :(

    1. There are two resources Resources.resx (English) and Resources.ru.resx(Russian).

    2. Form the form data is sent to the AA method.

    3. Method AA () form comes with model letters consist of the following fields:

    public class MyModel{public string Name { get; set; }
            public string Email { get; set; }
            public string Phone { get; set; }
            public string Message { get; set; }
            public string[] ListToEmail { get; set; }
            public HttpPostedFileBase File { get; set; }}

    4. The letter normally send all but user information is sent only in Russian from a resource file.

     public class AjaxController : SurfaceController
        { public ActionResult AA()
            {
                var nodes = CurrentPage.ContentSet.ToArray();
                var model = new MyModelView(nodes[1]); 
    return PartialView(model); } [HttpPost] public JsonResult AA(MyModel model) { try { //action return Json(new { Message = Resources.Resources.mail_success;, Success = true }, JsonRequestBehavior.AllowGet);
    } catch (Exception) { return Json(new { Message = Resources.Resources.mail_error, Success = false }, JsonRequestBehavior.AllowGet);
    } }

    How to make the right conclusions from the information resource file?

    There is an idea to do so:

    [HttpPost]
             public JsonResult AA(MyModel model)
    { var langId= umbraco.library.GetCurrentDomains(6085)[0].Language; try { //action var message = ""; switch (langId.id)
    { case 1: message = Resources.EnResources.mail_success; break; case 2: message = Resources.RuResources.mail_success; break; } return Json(new { Message = message, Success = true }, JsonRequestBehavior.AllowGet); } catch (Exception) { .... }

    but as I understand it is very ugly method :(

    Thanks in advance!:)

    p.s. Sorry for bad english

Please Sign in or register to post replies

Write your reply to:

Draft