Skip to content

Commit

Permalink
i18n polishing (#5542)
Browse files Browse the repository at this point in the history
Co-authored-by: David Glick <david@glicksoftware.com>
  • Loading branch information
erral and davisagli authored Jan 12, 2024
1 parent 7e64e03 commit 6eea25e
Show file tree
Hide file tree
Showing 20 changed files with 13,966 additions and 14,022 deletions.
11 changes: 5 additions & 6 deletions packages/scripts/i18n.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ function getMessages() {
function messagesToPot(messages) {
return map(keys(messages).sort(), (key) =>
[
`#. Default: "${messages[key].defaultMessage.trim()}"`,
...map(messages[key].filenames, (filename) => `#: ${filename}`),
`# defaultMessage: ${messages[key].defaultMessage}`,
`msgid "${key}"`,
'msgstr ""',
].join('\n'),
Expand All @@ -124,10 +124,10 @@ msgstr ""
"POT-Creation-Date: ${new Date().toISOString()}\\n"
"Last-Translator: Plone i18n <plone-i18n@lists.sourceforge.net>\\n"
"Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\\n"
"MIME-Version: 1.0\\n"
"Content-Type: text/plain; charset=utf-8\\n"
"Content-Transfer-Encoding: 8bit\\n"
"Plural-Forms: nplurals=1; plural=0;\\n"
"MIME-Version: 1.0\\n"
"Language-Code: en\\n"
"Language-Name: English\\n"
"Preferred-Encodings: utf-8\\n"
Expand All @@ -153,7 +153,7 @@ function poToJson({ registry, addonMode }) {
language === 'en'
? item.msgstr[0] ||
(item.comments[0]
? item.comments[0].replace('defaultMessage: ', '')
? item.comments[0].replace('. Default: ', '')
: '')
: item.msgstr[0];
}
Expand Down Expand Up @@ -212,7 +212,7 @@ function poToJson({ registry, addonMode }) {
*/
function formatHeader(comments, headers) {
return [
...map(comments, (comment) => `# ${comment}`),
...map(comments, (comment) => `#. ${comment}`),
'msgid ""',
'msgstr ""',
...map(keys(headers), (key) => `"${key}: ${headers[key]}\\n"`),
Expand All @@ -227,7 +227,6 @@ function formatHeader(comments, headers) {
*/
function syncPoByPot() {
const pot = Pofile.parse(fs.readFileSync('locales/volto.pot', 'utf8'));

map(glob('locales/**/*.po'), (filename) => {
const po = Pofile.parse(fs.readFileSync(filename, 'utf8'));

Expand All @@ -237,8 +236,8 @@ function syncPoByPot() {
${map(pot.items, (item) => {
const poItem = find(po.items, { msgid: item.msgid });
return [
`#. ${item.extractedComments[0]}`,
`${map(item.references, (ref) => `#: ${ref}`).join('\n')}`,
`# ${item.comments[0]}`,
`msgid "${item.msgid}"`,
`msgstr "${poItem ? poItem.msgstr : ''}"`,
].join('\n');
Expand Down
1 change: 1 addition & 0 deletions packages/scripts/news/5542.internal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Polish po file handling @erral
Loading

0 comments on commit 6eea25e

Please sign in to comment.