Dynamically load site language concurrent Language file

Dynamically load site language concurrent Language file

preformpreform Posts: 1Questions: 1Answers: 0

Hi, Is there a way of to use jscript or C# MVC variables for to set the language file or any of the Datatable settings.?

I would like to use resorce files for different languages to get a truly language dynamical site including the Datatables.net tables.

ie. I would like to use for instans..

  $(document).ready(function () {
         var Datatabledecimal = ",";
         var LanguageUrl= "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Swedish.json"
         $('#myTable').dataTable({
            "dom": 'lifrtpB',
            "deferRender": true,
            "order": [[0, "asc"]],
            "autowidth": true,
            "ServerSide": false,
            "stateSave": true,
            "lengthMenu": [
                [10, 25, 50, -1],
                ['10 ', '25 ', '50 ', 'All']],
            "language": {
                "Url": LanguageUrl,
                "decimal": Datatabledecimal,
                "thousands": ""
            },
            "paging": true
        });
    });

//What I really like to be able to do on a C3 MVC page is the following.

         <Script>
          var Datatabledecimal = @MyProject,Recource.DatatableDecimal;
          var LanguageUrl= @MyProject,Recource.DatatableLanguageUrl;
         </Script>

     $(document).ready(function () {

         $('#myTable').dataTable({
            "dom": 'lifrtpB',
             "deferRender": true,
             "order": [[0, "asc"]],
             "autowidth": true,
              "ServerSide": false,
              "stateSave": true,
              "lengthMenu": [
                  [10, 25, 50, -1],
                  ['10 ', '25 ', '50 ', 'All']],
               "language": {
                  "Url": LanguageUrl,
                  "decimal": Datatabledecimal,
                   "thousands": ""
               },
               "paging": true
          });
      });

//or even better.

 $(document).ready(function () {
         $('#myTable').dataTable({
            "dom": 'lifrtpB',
            "deferRender": true,
            "order": [[0, "asc"]],
            "autowidth": true,
            "ServerSide": false,
            "stateSave": true,
            "lengthMenu": [
                [10, 25, 50, -1],
                ['10 ', '25 ', '50 ', 'All']],
            "language": {
                "Url": @MyProject,Recource.DatatableLanguageUrl,
                "decimal": @MyProject,Recource.DatatableDecimal,
                "thousands": ""
            },
            "paging": true
        });
    });
This discussion has been closed.