New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More โ†’
Socket
Sign inDemoInstall
Socket

grunt-static-i18n

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-static-i18n

Grunt plugin to translate static assets.

  • 0.3.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

Static Internationalization

Build Status Coverage Status

Grunt plugin to translate static assets.

Say you have:

app/
โ”œโ”€โ”€ Gruntfile.js
โ””โ”€โ”€ app
    โ”œโ”€โ”€ locale
    โ”‚   โ”œโ”€โ”€ fr
    โ”‚   โ”‚   โ””โ”€โ”€ LC_MESSAGES
    โ”‚   โ”‚       โ””โ”€โ”€ messages.po
    โ”‚   โ””โ”€โ”€ pt_BR
    โ”‚       โ””โ”€โ”€ LC_MESSAGES
    โ”‚           โ””โ”€โ”€ messages.po
    โ””โ”€โ”€ static
        โ””โ”€โ”€ data.json  // content: ["_('Hello World')"]

And you need to translate data.json.
Static internationalization would like like:

app/
โ”œโ”€โ”€ Gruntfile.js
โ””โ”€โ”€ app
    โ”œโ”€โ”€ i18n
    โ”‚   โ”œโ”€โ”€ fr
    โ”‚   โ”‚   โ””โ”€โ”€ static
    โ”‚   โ”‚       โ””โ”€โ”€ data.json  // content: ["Bonjour tout le monde"]
    โ”‚   โ”œโ”€โ”€ pt_BR
    โ”‚   โ”‚   โ””โ”€โ”€ static
    โ”‚   โ”‚       โ””โ”€โ”€ data.json // content: ["Olรก mundo"]
    โ”‚   โ””โ”€โ”€ static
    โ”‚       โ””โ”€โ”€ data.json  // not translated: ["Hello World"]
    โ”œโ”€โ”€ locale
    โ”‚   โ”œโ”€โ”€ fr
    โ”‚   โ”‚   โ””โ”€โ”€ LC_MESSAGES
    โ”‚   โ”‚       โ””โ”€โ”€ messages.po
    โ”‚   โ””โ”€โ”€ pt_BR
    โ”‚       โ””โ”€โ”€ LC_MESSAGES
    โ”‚           โ””โ”€โ”€ messages.po
    โ””โ”€โ”€ static
        โ””โ”€โ”€ data.json

Getting Started

This plugin requires Grunt.

Translations are done with node-gettext and you will need a proper gettext catalog (structure seen above). If need help extracting translation strings, checkout grunt-i18n-abide. Checkout the makemessages task in Gruntfile.js.

The "statici18n" task

Overview

In your project's Gruntfile, add a section named statici18n to the data object passed into grunt.initConfig():

grunt.initConfig({
  statici18n: {
    options: {
      localeDir: 'app/locale'
    },
    myAppTask: {
      files: [{
        expand: true,
        cwd: 'app',
        src: 'static/*.{js,json}',
        dest: 'app/i18n'
      }]
    }
  }
})

Options

options.localeDir

Type: String Default value: locale

Sometimes easiest to use a var, say <%= abideCreate.options.localeDir %>

options.template.interpolate

Type: RegEx
Default: search for _('msgid') or _("msgid")

Used to find gettext calls.
Sets _.templateSettings.interpolate

options.textDomain

Type: String Default value: messages

Name of your po files: locale/<lang>/LC_MESSAGES/<textDomain>.po

Tests

Run grunt && open coverage.html

License

Copyright (c) 2014 Douglas Beck. Licensed under the MIT license.

Keywords

FAQs

Package last updated on 14 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc