Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpolation doesn't work on fallback locale in production mode #491

Closed
ppozniak opened this issue Apr 24, 2019 · 1 comment
Closed

Interpolation doesn't work on fallback locale in production mode #491

ppozniak opened this issue Apr 24, 2019 · 1 comment

Comments

@ppozniak
Copy link

Connected to:
#385

Describe the bug
Given I'm using webpack in production mode and "fallbackLocale": "en" is set in .linguirc
Given a trans component with some variable:

<Trans> Hello {name} </Trans>

When using i18nProvider and setupI18n

const catalogs = { en: enCatalog };
export const i18n = setupI18n({ catalogs, language: DEFAULT_LOCALE });

// ===
// Please note language is dynamic here, as it's taken from session config
      <I18nProvider
            i18n={i18n}
            language={sessionConfig.locale || DEFAULT_LOCALE}
            catalogs={catalogs}
          >

When language is set to existing catalog (en), everything works fine.

But when language is set to non existing catalog (let's say es), then interpolation won't work and "Hello {name}" will be rendered.

Expected behavior
It should interpolate strings, even if given catalog doesn't exists (given that fallbackLocale is set)

Additional context
Add any other context about the problem here.

  • jsLingui version 2.7.4
  • Babel version babel-core@7.0.0-bridge.0 + "@babel/core": "7.3.4",
  • Your Babel config
{
  "presets": ["@lingui/babel-preset-react", "@babel/preset-env", "@babel/preset-react"],
  "plugins": [
    "@babel/plugin-syntax-export-default-from",
    "@babel/plugin-proposal-class-properties",
    "babel-plugin-jsx-control-statements",
    "macros",
    "react-hot-loader/babel",
    [
      "module-resolver",
      {
        "root": ["./src"],
        "alias": {
          // Aliases here
        }
      }
    ]
  ]
}
@tricoder42
Copy link
Contributor

Hi @ppozniak,
unfortunatelly this is "expected". Since the messages are compiled at build time, there's no runtime parser and you can't format messages (e.g. default ones) at runtime.

Next version will probably support optional runtime parsing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants