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

Easily add translations within embeddedPages.welcomeUrl HTML file #10468

Open
eMPee584 opened this issue Jul 31, 2019 · 6 comments

Comments

@eMPee584
Copy link

commented Jul 31, 2019

(repost of matrix-org/matrix-android-sdk#461)
We have a customized welcome.html and have a few strings in there that we would like to provide translations for into another language. Is there any way (<script>magic</script>) to add these translations from within that file without modding i18n/strings/X.json, recompiling it into a bundle and overlaying it into the docker image we use?

@eMPee584 eMPee584 added the suggestion label Jul 31, 2019

@turt2live

This comment has been minimized.

Copy link
Member

commented Jul 31, 2019

Copying the code from the existing welcome page (_t("your string here")) and runnign yarn i18n over the project should pick them up. From there all you need to do is add the translations manually to the other language files and you're set.

If your audience is in a single specific language, I wouldn't bother with trying to translate anything and just put that language directly into the welcome page.

@turt2live turt2live added support and removed suggestion labels Jul 31, 2019

@jryans

This comment has been minimized.

Copy link
Member

commented Aug 1, 2019

Hopefully the comment above answers your question. 😁 If you need further help with this, I'd suggest asking in #riot-web:matrix.org, as the interactive medium is a bit better for support.

@jryans jryans closed this Aug 1, 2019

@eMPee584

This comment has been minimized.

Copy link
Author

commented Aug 1, 2019

Copying the code from the existing welcome page (_t("your string here")) and runnign yarn i18n over the project should pick them up.

Well not all that easy; debian stretch on that server = no yarn in repo. So by help of docker run -it --rm --name yarn -v /usr/src/repos/riot-web:/usr/src/riot-web -w /usr/src/riot-web node bash and manually yarn linking with matrix-react-sdk and stuff, I get the updated src/i18n/strings/en_EN.json. Now I can manually transfer the strings to my target language JSON then, and ...

From there all you need to do is add the translations manually to the other language files and you're set.

… then still would have to rebuild the whole thing and deploy my own riot version. Which I'm not going to do because of two-five strings. Which is why I specifically asked for a way to append a small number of translations from within the HTML itself using JS.

So, my issue is not resolved as I still have untranslated strings with a target audience of two languages (EN, DE)..

@eMPee584

This comment has been minimized.

Copy link
Author

commented Aug 1, 2019

Ok so basically, the t() function is defined in matrix-react-sdk/src/languageHandler.js and uses the counterpart library, which uses an in-memory dict. So there should be an easy way to insert a few keys into that array after i18n/languages.json has finished loading..

@jryans

This comment has been minimized.

Copy link
Member

commented Aug 2, 2019

Well not all that easy; debian stretch on that server = no yarn in repo.

It's likely possible to use npm as well, if that's easier to access. (We moved away from it because the linking behaviour is not great: the links are removed every time you npm install, so you have to keep relinking.)

@jryans jryans changed the title How to add translations within embeddedPages.welcomeUrl HTML file? Easily add translations within embeddedPages.welcomeUrl HTML file Aug 2, 2019

@jryans jryans added suggestion and removed support labels Aug 2, 2019

@jryans

This comment has been minimized.

Copy link
Member

commented Aug 2, 2019

Okay, I have flipped this back to a suggestion and reopened since it seems like there's some space to simplify this process somehow.

@jryans jryans reopened this Aug 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.