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

I18N support + translation #18

Open
1 task
srid opened this issue Dec 27, 2023 · 6 comments
Open
1 task

I18N support + translation #18

srid opened this issue Dec 27, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@srid
Copy link
Member

srid commented Dec 27, 2023

Basic support for translation is in place. English articles are in en/ folder. For other languages, create a similar file structure in the corresponding language folder. Translations can already happen.

But the website static site generation will need to be tweaked a bit, which I'll do.

cc @brsvh for past discussion on this at juspay/flakular.in#11

Tasks

@srid srid added the enhancement New feature or request label Dec 27, 2023
@brsvh
Copy link

brsvh commented Dec 28, 2023

I have started trying, and it's working well, but there are still some feature I'm unsure how to fulfill.

  • How do I switch languages? I have looked at emanote and it appears to lack such a component, it seems we need to implement an additional language switching component.
  • How should I go about localizing some UI interfaces? For example, the "Home" navigation in the sidebar, the "Links to this page" text in the area displaying all folgezettel links, and most of the tooltips.

Temporary preview: nix run github:brsvh/nixos.asia/l10n/zh-Hans#preview -- -o /zh-Hans

@brsvh
Copy link

brsvh commented Dec 28, 2023

  • How do I switch languages? I have looked at emanote and it appears to lack such a component, it seems we need to implement an additional language switching component.
  • How should I go about localizing some UI interfaces? For example, the "Home" navigation in the sidebar, the "Links to this page" text in the area displaying all folgezettel links, and most of the tooltips.

I think this can be summarized as two other questions:

  • How to set the expected language of a page and generate different content based on it.
  • How to detect the local preferred language of users.

For the former, I want to try to make the default theme of emanote get better template generation capabilities based on language tags. I have created a discussion.

For the latter, I know that I can get them through the user's browser environment navigator.language, navigator.browserLanguage or system environment. It seems that it can be done by additional JS, but I'm not quite sure about doing it entirely in the template.

But in any case these problems do not affect the translation of existing articles.

@srid srid mentioned this issue Dec 28, 2023
3 tasks
@brsvh
Copy link

brsvh commented Jan 3, 2024

It seems like we can't maintain a consistent directory structure across languages. I always catch duplicate errors for backlinks.

...
[Info#ema.generate] W /nix/store/xq8m44y0fprp8m9sa5xlfd8b4j80n8y0-emanote-static-website/en/tutorial.html
[Info#ema.generate] W /nix/store/xq8m44y0fprp8m9sa5xlfd8b4j80n8y0-emanote-static-website/en/tutorial/nixos-install.html
[Info#ema.generate] W /nix/store/xq8m44y0fprp8m9sa5xlfd8b4j80n8y0-emanote-static-website/en/configuration-as-flake.html
...
[Info#ema.generate] W /nix/store/xq8m44y0fprp8m9sa5xlfd8b4j80n8y0-emanote-static-website/zh-Hans/tutorial.html
[Info#ema.generate] W /nix/store/xq8m44y0fprp8m9sa5xlfd8b4j80n8y0-emanote-static-website/zh-Hans/tutorial/nixos-install.html
[Info#ema.generate] W /nix/store/xq8m44y0fprp8m9sa5xlfd8b4j80n8y0-emanote-static-website/zh-Hans/configuration-as-flake.html
...
[Warn#emanote] Ambiguous link: Left R[/en.md] -> URTWikiLink (WikiLinkBranch,[[tutorial]]) ambiguities: "en/tutorial" :| ["zh-Hans/tutorial"]
[Warn#emanote] Ambiguous link: Left R[/en/nixos.md] -> URTWikiLink (WikiLinkNormal,[[nixos-install]]) ambiguities: "en/tutorial/nixos-install" :| ["zh-Hans/tutorial/nixos-install"]
[Warn#emanote] Ambiguous link: Left R[/en/tutorial/nixos-install.md] -> URTWikiLink (WikiLinkEmbed,[[configuration-as-flake]]) ambiguities: "en/configuration-as-flake" :| ["zh-Hans/configuration-as-flake"]
[Warn#emanote] Ambiguous link: Left R[/zh-Hans.md] -> URTWikiLink (WikiLinkNormal,[[tutorial]]) ambiguities: "en/tutorial" :| ["zh-Hans/tutorial"]
[Error#emanote] Found 4 broken links! Emanote generated the site, but the generated site has broken links.

If I use the new directory structure (Chinese names), everything works fine.

tree zh-Hans
zh-Hans
├── 教程
│   ├── nixos-安装
│   │   └── 使用flake进行配置.md
│   └── nixos-安装.md
└── 教程.md

3 directories, 3 files

I think inconsistent naming with the original files is bad, do you have any suggestions?

@srid
Copy link
Member Author

srid commented Jan 3, 2024

@brsvh Yea, I noticed that as well. If you use [[tutorial]], it will be ambiguous due to multiple languages. You can resolve that using [[en/tutorial]] - but I don't think that's a desirable solution. I think we may have to end up having to separate Emanote sites for each language folder (assuming no interlinking between them). Let me think about it.

I have an international trip to India later this week, so I'll be slow in responding. Feel free to join our Zulip as well for interactive conversation: https://nixos.zulipchat.com/

@srid srid mentioned this issue Jan 4, 2024
6 tasks
@srid
Copy link
Member Author

srid commented Jan 4, 2024

I think we may have to end up having to separate Emanote sites for each language folder (assuming no interlinking between them). Let me think about it.

Inclined to go with this for now: #21

Later on, when Emanote itself gets native i18n support (srid/emanote#486) we can figure out better integration of top-level language layers in an unified single Emanote site.

@srid
Copy link
Member Author

srid commented Jan 16, 2024

srid/emanote#498 resolves ambiguous links more sensibly, which would allow us to go back to 'singe notebook' approach. So [[foo]] would link to [[en/foo]] if the linking note exists in en/ even if there is zh-Hans/foo.md.

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

No branches or pull requests

2 participants