gettext-loader
gettext-loader copied to clipboard
questions for .po file generation
hi, when I run webpack, I see an undefined.po file gets generated at the root of my project.
- the contents of the .po file look like
- "0 : [object Object]"
this is what the contents of my gettext.config.js looks like:
module.exports = {
methods: ['$translate', 't'],
header: [{
'Project-Id-Version': 'PROJECT VERSION',
'Report-Msgid-Bugs-To': 'EMAIL@ADDRESS',
'Last-Translator': 'FULL NAME <EMAIL@ADDRESS>',
'Language': 'es',
'Language-Team': 'es <[email protected]>',
'Plural-Forms': 'nplurals=2; plural=(n != 1)',
'MIME-Version': '1.0',
'Content-Type': 'text/plain; charset=utf-8',
'Content-Transfer-Encoding': '8bit'
}]
};
I'm not clear if I'm setting the methods property correctly. I'm trying to use the i18n.t() function for translations. thanks.
- is root the default location where .po files will get built and how could I change that?
- can I build multiple .po files at once?
- how should I set the .po file name
All good questions! Just off the top of my head:
Maybe it will work if you take out the array brackets in the 'header' value. The code expects header to be an object.
Other than that your config looks fine.
The root project folder is where the .po
file will be built. I have not documented this yet (among other things), but you can change the location and name of the output file by adding an 'output' value in the config object.
{
output: 'i18n/custom-name.po'
}
Adding this to your config would change the output location to the folder 'i18n' and change the name of the output file to 'custom-name.po'. ( I believe I have to change a little bit of code to make this work)
Currently, only one .po
file is supported.
I can dig in deeper and write up some more documentation after work today.
@cch5ng
I just re-hauled the loader and multiple issues have been fixed.
if you want to use the method i18n.t()
simply add 't' to the list of methods.
Currently only one output .po
file is supported. Is there a use case for having multiple .po files for the same language?
I've actually thought of enabling multiple .po
support where a .po
file is generated per file, but I'm not sure if this is something people want. In end, at least from my experience, all the .po
files will have to be combined together and sent to a translator like Transifex.
@mrblueblue
thanks for your note and update. I agree that it makes sense to support just one .po file. I do not think there is a use case for multiple .po files at this time.
I will check out your changes and let you know if I have feedback. thanks again. is your policy not to close issues and leave them open until the original requestor closes them? my project priorities shifted and so I will probably get back to this Sun. or after.
A use case for multiple po files... If you combine this with something like po-loader; you can use webpack's code splitting to create language bundles for only the loaded components, instead of having to download the site's entire language pack...