Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
grunt-static-i18n
Advanced tools
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
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.
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'
}]
}
}
})
Type: String
Default value: locale
Sometimes easiest to use a var, say <%= abideCreate.options.localeDir %>
Type: RegEx
Default: search for _('msgid')
or _("msgid")
Used to find gettext calls.
Sets _.templateSettings.interpolate
Type: String
Default value: messages
Name of your po files: locale/<lang>/LC_MESSAGES/<textDomain>.po
Run grunt && open coverage.html
Copyright (c) 2014 Douglas Beck. Licensed under the MIT license.
0.3.3
Bumps node-gettext, which uses "iconv-lite" instead of "iconv" and removes the need for native code compilation.
FAQs
Grunt plugin to translate static assets.
We found that grunt-static-i18n demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.ย It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.