Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9269821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:13:06+00:00 2026-06-18T15:13:06+00:00

I want to do some basic i18n in my application I loaded the i18n

  • 0

I want to do some basic i18n in my application

I loaded the i18n plugin (from require.js) to my Application and created a directory nls in which i have several files e.g. project.js

I set up the default location in main.js file like

config : {
    i18n : {
        locale : 'de-de'
    }
}

I now want to use the files in my View / Template. Can somebody explain to me how this is done? The templates are setup in one template.js file

My View:

define(['marionette', 'templates', 'i18n!nls/project'], function (marionette, templates, msg) {

    return marionette.CompositeView.extend({
        template : templates.project
    });

});

My template:

<div class="container">
    <div class="well">
        <h2>Projects</h2>
    </div>
</div>

Can someone explain to me how to use the file in my View / Template? Thanks in advance!

EDIT:

I figured out the solution by some try&error. As i am loading the templates via the require.js tpl! plugin i dont need to compile them if i call them by require('tpl!templates/dashboard.tmpl'). I can simply pass the i18n file i loaded by 'i18n!nls/dashboard'. In Marionette the view are rendered by default, so i did this:

define(['marionette', 'templates', 'i18n!nls/dashboard'], function (Marionette, templates, msg) {

    return Marionette.CompositeView.extend({

        template : function () {
            return templates.dashboard(msg);
        },

        initialize : function() {

        }
    });

});

The files for the i18n plugin are well explained here:
http://requirejs.org/docs/api.html#i18n

I had to do this step by step, first i missed the root, then i wondered why my german locale did not load, but i simply forgot to set de-de : true in the root file. Now everything is working like a charm

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:13:08+00:00Added an answer on June 18, 2026 at 3:13 pm

    first you load the i18 file via require.js to your view.
    I use the handlebars templates in this example.

    define([
        'marionette',
        'handlebars',
        'text!modules/tableModule/templates/myTmpl.html',
        'i18n!nls/dashboard',
    ],
    function(Marionette, Handlebars, tmpl, locals) { ...
    

    then you compile and load your template with the i18 object.

    var template = Handlebars.compile(tmpl);
    this.template = template(locals.myVar);
    

    you can go and do complex combinations as well

      var template = Handlebars.compile(tmpl);  
      var data =_.extend(options, {lang:locals});
      this.template = template(data); 
    

    your nls file will look like this

    define({
    
        "root": {
             "myVar" : "some text in",
             "canBeAnObjectTo": {
                          "title"   : "my title ",
                          "contact" : "Contact",
                }
    

    and your view will be something like this:

      <div class="cssClass">
    <div class="table-caption pull-left">{{this.myVar}}</div>
      </div>
    

    hope that helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to replace some text to other text which contains elements of basic
So I have some nav anchors. I want to change some basic color schemes
I simply want some tabbing functionality on a facebook application (business) tabs I have
Ok. I know this is very basic. I want to have some basic tags
I want to do some basic String testing in Node.js. Assume I have a
I have java code written in eclipse and I want to show some basic
i am writing a client/server application. Now i want to do some basic diagrams
I want to implement some basic tracing in a simple c# (WPF) application that
Hi have some forms that I want to use some basic php validation (regular
Let's say I want to add some basic encryption capabilities to my application (without

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.