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

Use bindtextdomain() hack to reset cache #175

Merged
merged 1 commit into from
Nov 29, 2021
Merged

Conversation

hadley
Copy link
Member

@hadley hadley commented Nov 8, 2021

Per r-lib/withr#183, I think this should be adequate.

Let me know if you think I should construct a test that illustrates the problem and the fix.

@gaborcsardi
Copy link
Member

This does not work for me on macOS CRAN R 4.1.1:

pkgload::load_all()
ℹ Loading testTranslations

❯ hello()
[1] "Hello"

❯ Sys.setenv(LANGUAGE="fr")
❯ hello()
[1] "Bonjour"

# Now edit the `po/R-fr.po` file and run
# `msgfmt -c --statistics -o inst/po/fr/LC_MESSAGES/R-testTranslations.mo po/R-fr.po`pkgload::load_all()
ℹ Loading testTranslations

❯ hello()
[1] "Bonjour"

The translation is not updated.

As a sanity check, if I restart R, then of course the new translation is loaded:

❯ R -q -e 'pkgload::load_all(); Sys.setenv(LANGUAGE="fr"); hello()'
> pkgload::load_all(); Sys.setenv(LANGUAGE="fr"); hello()
ℹ Loading testTranslations
[1] "Salut"

@hadley
Copy link
Member Author

hadley commented Nov 9, 2021

Ok, I'll definitely construct a better test then.

@jimhester jimhester merged commit 19fadb8 into main Nov 29, 2021
@lionel- lionel- deleted the load-po-simplify branch December 2, 2021 13:35
hadley added a commit that referenced this pull request Dec 6, 2021
hadley added a commit that referenced this pull request Dec 6, 2021
Reverts #175 adding tests to prove that it doesn't work
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

Successfully merging this pull request may close these issues.

3 participants