Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Nov 29 18:25
    semoal closed #1173
  • Nov 29 17:57
    alexbu92 opened #1173
  • Nov 27 11:51
    semoal closed #1169
  • Nov 26 14:48
    semoal labeled #1157
  • Nov 26 14:48
    semoal labeled #1157
  • Nov 26 14:48
    semoal closed #1149
  • Nov 26 14:47
    semoal closed #1145
  • Nov 26 14:46
    semoal closed #1164
  • Nov 26 14:45
    semoal labeled #1167
  • Nov 26 14:45
    semoal labeled #1167
  • Nov 26 14:42
    semoal labeled #1169
  • Nov 26 14:42
    semoal labeled #1169
  • Nov 26 14:42
    semoal labeled #1154
  • Nov 26 14:42
    semoal labeled #1154
  • Nov 26 14:29
    semoal closed #1172
  • Nov 26 14:29
    semoal edited #1172
  • Nov 26 14:28
    semoal closed #1170
  • Nov 26 14:28
    semoal edited #1170
  • Nov 26 14:27
    semoal closed #1166
  • Nov 26 14:27
    semoal closed #1162
Daniel K.
@FredyC
@burkov I don't think there is a "best approach", each as it's own issues, do you want smart backend or smart client, that's what you should decide :)
Mike Williamson
@sleepycat
Congrats on shipping 3.0!
Hector
@hectorcoronado
Hi all, quick question: to anyone's knowledge, is it possible to make the setupI18n function async? I.e. is there a way to do something like the following pseudocode:
export const getI18n = async (lang) => {
    const catalog = await import (/lang/messages.js)
       .then(result => setupI18n(lang, {[lang]: result})
   return catalog
}
Daniel K.
@FredyC
@hectorcoronado And what's the problem, it's already async this way :) Promise.then doesn't care if you return another Promise or static value, it's already chained
learn about promises, this isn't about Lingui really
Hector
@hectorcoronado
@FredyC the issue I'm running into is that whenever I write it out like this, I get a "I18n.load" is not a function wherever I'm importing the getI18n function
Daniel K.
@FredyC
then you are doing something else that what you are not showing
Hector
@hectorcoronado
@FredyC thanks for the quick responses -- I've outlined the issue I'm facing in more detail here (but perhaps that's not the correct place for it); any insight or input you might provide would be very much appreciated
Ivan Storck
@ivanoats
This may be kind of a n00b question, but still stuck. I'm getting a couple of errors after re-doing my yarn.lock file. (I know, not the best idea) "TypeError: Cannot read property 'locale' of undefined" and "Error: useLingui hook was used without I18nProvider". Has anyone run into this situation before?
Roy Pearce
@roypearce
Screen Shot 2020-11-05 at 3.17.36 PM.png
I just upgraded to 3.0.3 from 2.9.6 in the hopes that it would solve an issue I have where in a React app while developing locally everything works as expected, but in staging (through a production build process) a lot of templatized strings with variables will not appear properly, this is with react/webpack/babel. In 2.9.6 the Trans tags worked fine, it was the t macro that had this issue, but in 3.0.3 both have this issue in production (it's fine in dev)
Roy Pearce
@roypearce
I've been able to repro it locally by running webpack dev server with webpack in production mode. If the only thing I change in my webpack config is mode from production to development it works again. I've tried turning on all the webpack production defaults I could find to see if I could recreate the bug in development mode to find an option that is causing the issue, but was unable to find one. I'm not sure what to do here. I'm hoping someone who has a better understanding of what may be going on can chime in.
Cezar Neaga
@cezarneaga
hi @tricoder42 & all, i have a question regarding v3: i was using in v2
<input placeholder={t('app.placeholder')`search here`} />
i noticed that the new t macro doesnt allow anymore for an id to be passed. any idea how to work around this? i couldnt find anything in the docs as i believe the docs there are still v2
Cezar Neaga
@cezarneaga
at least the types dont.
Tomáš Ehrlich
@tricoder42
Yeah, it'll be added in 3.1:
<input placeholder={t({ id: 'app.placeholder', message:`search here`}) />
It should be released today or tomorrow
Cezar Neaga
@cezarneaga
cheers. thank you
Cezar Neaga
@cezarneaga
does the use of thello need to be wrapped in something else in order to work? i am getting an reference error at runtime that t is not defined
Tomáš Ehrlich
@tricoder42
no, it should work as it is... if you're getting a runtime error, it's better to create a codesandbox so we can debug it
Cezar Neaga
@cezarneaga
:) i would need that monorepo setup
Roy Pearce
@roypearce
I've created a repro repo that is very basic that illustrates the issue https://github.com/roypearce/lingui-test If you do npm run dev and go to http://localhost:3020/ you will see "Welcome, Jon" if you run npm run dev:production you will see "Welcome, {name}". The only difference between the two scripts is the second runs webpack in production mode. If anybody has a second and can take a look I'd be very appreciative. This seems like the best option out there so I would love to get it working in prod.
3 replies
Cezar Neaga
@cezarneaga

:) i would need that monorepo setup

the upgrade to 3.1.0 solved the error above

Cezar Neaga
@cezarneaga

@tricoder42 in v2 we could build an object containing translated strings:
eg:

export const messages: { [key: string]: any } = {
    title: t('title')`awesome titel`,
    subtitle: t(
        'subtitle'
    )`awesome titel`,

and use import it in another file and

import {messages} from './messages'
...
//and consume it like this:
title: i18n._(messages.vpsBackupTitle)

if i translate the object to new syntax:

export const messages: { [key: string]: any } = {
    title: t({ id: 'title', message: `awesome titel` }),
    subtitle: t({
        id: 'subtitle',
        message: `some subtitle`,
    }),
}

how should i consume it in another file?

Cezar Neaga
@cezarneaga
i tried
import { useLingui } from '@lingui/react'
import {messages} from './messages'

...
//and consume it like this:
const {i18n} = useLingui()
title: i18n._(messages.vpsBackupTitle)
it shows the source language text instead of translation
13 replies
Cezar Neaga
@cezarneaga

@tricoder42 in v2 we could build an object containing translated strings:
eg:

export const messages: { [key: string]: any } = {
    title: t('title')`awesome titel`,
    subtitle: t(
        'subtitle'
    )`awesome titel`,

and use import it in another file and

import {messages} from './messages'
...
//and consume it like this:
title: i18n._(messages.vpsBackupTitle)

title: i18n._(messages.title)

Roy Pearce
@roypearce
Screen Shot 2020-11-10 at 12.02.56 PM.png
Are the types not being generated for each release?
It looks like the types are from an old release (using 3.1.0)
Alexander Wallace
@telpochyaotl
Hi all! in V 3.1.0 is it still recommended to load the .po files in the app instead of compiled?
Alexander Wallace
@telpochyaotl
as in the examples/create-react-app
Alexander Wallace
@telpochyaotl
I guess all of that works…
My issue right now, is that, after generating PO files, the non source locales are missing all the “msgstr” strings and while this was not an issue before, and I do have fallbackLocales configured, the app errors out when switching to any other locale… If i copy the source locale to the other files then there is no problem…. Maybe some new default or config i’m missing ?
Alexander Wallace
@telpochyaotl
This issue only happens when i upgrade from 3.0.3 to 3.1.0 no other changes…
OrlandoCo
@OrlandoCo
Hi guys, after upgrading to latest create-react-app and latest lingui v3, I keep getting this error:
_lingui_core__WEBPACK_IMPORTED_MODULE_15__.i18n._(...) is not a function
1 reply
thisis for non react component s
Roy Pearce
@roypearce
I'm curious what other people's strategies are for updating the content of messages over time, especially if an id is being used. For example, if I do an extract with an id, I get the msgid & msgstr in the messages.po file just fine. However if I update the message in my source code at a later date and then do an extract, the msgstr is not updated. How do people keep things in sync? There are two reasons I see for using id's: when the message is very long to keep the compiled message file size down, or to minimize effort for retranslating long messages if a translating system is set up to show diff's of the change to the message.
Cezar Neaga
@cezarneaga
have discussions moved somewhere else? this is a bit too quiet
Tomáš Ehrlich
@tricoder42
well, there's also https://spectrum.chat/linguijs and we're trying to get GitHub Discussions for LinguiJS repo to consolidate communications channels.
Cezar Neaga
@cezarneaga
ok. :)
Ivan Vlatković
@ivandotv
Is there a way to pass in comments for generated .po file, so translators can have some context?
Tomáš Ehrlich
@tricoder42
Yes, you can use comment prop. simply search comment on this page https://lingui.js.org/ref/macro.html, there examples for react and js macros
BIG ANNOUNCMENT: GitHub Discussions for js-lingui channel have been enabled. Please use them instead of Gitter https://github.com/lingui/js-lingui/discussions
See you all there! :)
Raif Harik
@reharik
Hi not a lot of traffic here. Anyway, just started using lingui and am very pleased. Need a few pointers though. FIrst question, is it possible to explicitly create a key and default. I have dynamic strings being created and as far as I can tell I"m going to have to create the key/default explicitly.
Daniel Büchele
@danielbuechele
Hey, I just started using lingui and really like it. I have a question regarding the recommended use of the library: My project is translated into two languages, English is the default language. Lingui creates a translations file for English, but essentially the keys and values in this file would be identical. This feels unnecessary. Am I doing something wrong?
Jesus Lencina
@yisudev
Hey! Just by importing the Trans component from @lingui/macro, I get the following error: ./src/components/Navbar/Navbar.tsx
TypeError: /pathToTheProject/src/components/Navbar/Navbar.tsx: Cannot read property 'path' of undefined
importing from @lingui/react works, but I prefer to use the children prop, so any ideas?