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.

Interpolation broken by change in 3.13.1

See original GitHub issue

Describe the bug We upgraded from LinguiJS 3.13.0 to 3.13.1 and started seeing many errors logged in the console, all looking like this:

Plurals for locale en aren't loaded. Use i18n.loadLocaleData method to load plurals for specific locale. Using other plural rule as a fallback. 

We are definitely loading the locale data though, so we investigated further.

Looking into the few changes in 3.13.1, the only significant commit seems to be f8f47a2. And ignoring the formatting changes in that commit, the only functional change that I can find is that it bypasses the property getters for locale, locales, and localeData when calling interpolate(). To be honest, I have no idea why that would have fixed the problem that a locale did not get immediately activated?

In any case, while bypassing the getters for locale and locales makes no functional difference, bypassing the getter for localeData seems to break the functionality. _localeData is of type AllLocaleData, but localeData is of type LocaleData, and the getter looks like this:

  get localeData(): LocaleData {
    return this._localeData[this._locale] ?? {}
  }

So really you can’t substitute localeData with _localeData as they are different things, causing the error inside the interpolate function.

To Reproduce

I am not sure if there’s anything specific required to trigger the error, as far as I can tell we’re using Lingui in a pretty basic way.

import {i18n, Messages} from '@lingui/core';
import {I18nProvider} from '@lingui/react';
import {en as enPlurals, type PluralCategory} from 'make-plural/plurals';
import {messages as enMessages} from '~/src/i18n/en.po';

i18n.loadLocaleData({
  en: {plurals: enPlurals},
});
i18n.load('en', enMessages);
i18n.activate('en');

function Foo() {
  return <Trans>Hello</Trans>;
}

Expected behavior The console shouldn’t be full of the above error 😃

Additional context

  • jsLingui version 1.3.1
  • Babel version @7.16.10
  • Using @lingui/loader with Webpack 5.67.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
semoalcommented, Jan 22, 2022

Damn, you’re right. Will push a fix today

3reactions
cmlenzcommented, Jan 24, 2022

Looks good now, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Interpolate Loss Development Factors - Actuarial 101
This video demonstrates how to interpolate loss development factors using two simple interpolation techniques. Sections0:00 - Intro0:39 ...
Read more >
Interpolation - MathWorks
It overshoots the changes in the data values. As a result, full- degree polynomial interpolation is hardly ever used for data and curve...
Read more >
Developer Guide: Interpolation - AngularJS: API
Dynamically changing an interpolated value. You should avoid dynamically changing the content of an interpolated string (e.g. attribute value or text node).
Read more >
The Interpolation Problem in 1D - Florida State University
bad data locations {xi } can doom the process; a bad basis for the interpolating space can cause unbounded error; a function may...
Read more >
Cubic Spline Interpolation - Value-at-Risk: Theory and Practice
2.10 Cubic Spline Interpolation · Each polynomial passes through its respective end points: [2.113] · First derivatives match at interior points: [2.114] ·...
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