Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

POtoJS Loader

Transform a .po file to a Javascript Object

Install

npm install --save-dev potojs-loader
require('./languages/it_IT.po');

console.log(__it('Test to translate'));
// Test da tradurre

// or (if you have more language ==> alldir = true)
console.log(__('Test to translate', 'it', 'default traduction'))

The function __(testToTranslate, [lang, [default text]]). If the traduction is not defined and the default text is not defined return the "testToTranslate" string

 {
  test: /\.po$/,
  use: [
    {
      loader: 'potojs-loader',
      options: {
        'alldir': false,
        'setName': function (filename) {
          ...
          return language // ex: en | it | es ...
        }
      }
    }
  ],
 }

If the alldir option is set to true, the parser scan all directory of the po file looking for all other po file in the same directory and merge all the translates in only one big javascript object.

You can pass a function for generate a custom "lang" param for every po file with the setName option. By default the "lang" param is the first two character in the language code present in the name of file; example: if the file's name is wp-theme-en_US.po the "lang" param is en

About

Convert translate po file into a javascript's dictionary

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages