question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CLI command `extract --overwrite` deletes msgstr values in source locale po file

See original GitHub issue

Describe the bug

The first time lingui extract --overwrite is run then it generates po file entries for the source locale with identical msgid and msgstr values, e.g.

#: src/file.ts:105
msgid "Hello world"
msgstr "Hello world"

But then future runs of lingui extract --overwrite will remove the msgstr values in existing unedited entries, and changes the above to,

#: src/file.ts:105
msgid "Hello world"

This renders the source locale po file seemingly invalid, and breaks integrations with some cloud translation services like CrowdIn with errors like The imported messages.po localization file is invalid. GetText PO validation module said: line ###: missing msgstr section.

To Reproduce

Config looks like

module.exports = {
  sourceLocale: 'en',
  srcPathDirs: ['<rootDir>/src'],
  format: 'po',
  sorting: 'origin',
  localeDir: '<rootDir>/src/locale',
}

And we’re just using the plain JS approach (not React), e.g.

import { t } from '@lingui/macro'
i18n._(t`Hello world`)

Expected behavior

Repeated runs of lingui extract --overwrite do not remove msgstr entries for existing translations in the source locale po file. Although this is an assumption, and my understanding of the process may be faulty.

Additional context

Add any other context about the problem here.

  • jsLingui version 2.9.1
  • Babel version babel-core@7.0.0-bridge.0
  • Your Babel config
module.exports = {
  presets: [
    [
      '@babel/preset-env',
      {
        targets: {
          node: '10',
        },
        modules: 'cjs',
      },
    ],
    '@babel/typescript',
  ],
  plugins: [
    '@babel/proposal-class-properties',
    '@babel/proposal-object-rest-spread',
    'macros',
  ],
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ThiefMastercommented, Nov 2, 2020

any update on this? I don’t think it should be [wontfix]…

0reactions
stale[bot]commented, Jan 4, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GNU gettext utilities
Program xgettext extracts all marked messages from a set of C files and initializes a PO file with empty translations. Program msgmerge takes...
Read more >
Extract single translation from gettext .po file from shell
This is a nice solution and I could make it work in principle. However it does not provide translations for many locales (i.e....
Read more >
GNU gettext utilities - 6 Updating Existing PO Files
Go to the first, previous, next, last section, table of contents. 6 Updating Existing PO Files · 6.1 Invoking the msgmerge Program.
Read more >
The complete guide to internationalization in Next.js
Learn how to make your Next.js app international with smooth translation features in this advanced, step-by-step tutorial.
Read more >
ember-l10n - npm
Note: Addon's CLI commands will check dependencies for you and install ... After receiving the translated po files for additional locales, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found