Skip to content

gunjam/marko-i18next

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

i18next Marko tag lib

This tag lib allows you to access the i18next t() function from your request object (if for example you're using i18next Express middleware) in your templates if streaming to a response using the template.render() function:

template.render({}, res);

Installing

npm install marko-i18next

Usage

Example locales file (namespace.json):

{
  "message": "Hi guys",
  "interpolatedMessage": "Hi {{name}}",
  "submit": "Submit form",
  "nameSubmit": "Submit form for {{name}}"
}

<i18n-message/> component

In a Marko template:

<p>
  <i18n-message key="namespace:message"/>
</p>

With interpolated strings:

<p>
  <i18n-message key="namespace:interpolatedMessage" name="Hammond Eggs"/>
</p>

<i18n-var/> compile time variable

You can also add the translation function to your template by including <i18n-var/> at the top of the file. This is useful for assigning i18n messages to attributes:

<i18n-var/>

<form>
  ...
  <input type="submit" value=i18n('namespace:submit')/>
</form>

With interpolated strings:

<i18n-var/>

<form>
  ...
  <input type="submit" value=i18n('namespace:nameSubmit', {name: 'George'})/>
</form>

Contributing

Do a pull request, I'll have a look!

About

Components to use i18next in Marko templates.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published