Force interface language by config file #792

已關閉
DearRude wants to merge 1 commits from DearRude/force-lang into master
DearRude " 評論 4 年之前" (Migrated from github.com)

As explained in #785, trying to force the language interface which specified in .env file.

I tried the commented code below and re-compiled the front, but nothing happened. Since I didn't find any other piece which gets browser language, I assume my method of recompilation is flawed. (Only do cargo web deploy -p plume-front --release)

So I made this WIP PR as @igalic suggested. 😁

As explained in #785, trying to force the language interface which specified in `.env` file. I tried the commented code below and re-compiled the front, but nothing happened. Since I didn't find any other piece which gets browser language, I assume my method of recompilation is flawed. (Only do `cargo web deploy -p plume-front --release`) So I made this WIP PR as @igalic suggested. 😁
codecov[bot] " 評論 4 年之前" (Migrated from github.com)

Codecov Report

Merging #792 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #792      +/-   ##
==========================================
- Coverage   39.09%   39.08%   -0.02%     
==========================================
  Files          73       73              
  Lines        9756     9756              
  Branches     2233     2233              
==========================================
- Hits         3814     3813       -1     
  Misses       4885     4885              
- Partials     1057     1058       +1     
# [Codecov](https://codecov.io/gh/Plume-org/Plume/pull/792?src=pr&el=h1) Report > Merging [#792](https://codecov.io/gh/Plume-org/Plume/pull/792?src=pr&el=desc) into [master](https://codecov.io/gh/Plume-org/Plume/commit/d99b42582d7a5a8c8087b6ebe067b944cae0c294&el=desc) will **decrease** coverage by `0.01%`. > The diff coverage is `n/a`. ```diff @@ Coverage Diff @@ ## master #792 +/- ## ========================================== - Coverage 39.09% 39.08% -0.02% ========================================== Files 73 73 Lines 9756 9756 Branches 2233 2233 ========================================== - Hits 3814 3813 -1 Misses 4885 4885 - Partials 1057 1058 +1 ```
elegaanz " 評論 4 年之前" (Migrated from github.com)

The issue with the front-end is that it runs in the browser: it can't access the environment variables of the server.

I think the solution would be to:

  • first, do this change on the server side, where you can access the environment variables from the configuration. This may require you to change Plume-org/rocket-i18n first
  • then, once this settings works on the server, add a lang property to every <html> tag we render, containing the language code that we chose to render the page
  • in the front-end, use this lang attribute to detect the language instead of relying on navigator.language as we currently do.

I hope this isn't too much. I can try to guide you more if need detailed steps, I know it can be hard to get started on a codebase you know nothing about. Feel free to ask me here or on Matrix if you have any questions.

The issue with the front-end is that it runs in the browser: it can't access the environment variables of the server. I think the solution would be to: - first, do this change on the server side, where you can access the environment variables from the configuration. This may require you to change Plume-org/rocket-i18n first - then, once this settings works on the server, add a `lang` property to every `<html>` tag we render, containing the language code that we chose to render the page - in the front-end, use this `lang` attribute to detect the language instead of relying on `navigator.language` as we currently do. I hope this isn't too much. I can try to guide you more if need detailed steps, I know it can be hard to get started on a codebase you know nothing about. Feel free to ask me here or on Matrix if you have any questions.
所有者

I assume my method of recompilation is flawed. (Only do cargo web deploy -p plume-front --release)

The feature is missing, so it's not the issue at hand, but doing just that was actually not sufficient. You must also rebuild Plume, as it's build script (build.rs) is the one copying files from target/ to where static files should be

> I assume my method of recompilation is flawed. (Only do `cargo web deploy -p plume-front --release`) The feature is missing, so it's not the issue at hand, but doing just that was actually not sufficient. You must also rebuild Plume, as it's build script (build.rs) is the one copying files from `target/` to where static files should be
所有者
> [I give up on this. Could not make it work...](https://github.com/Plume-org/Plume/pull/792#issuecomment-650167801)
trinity-1686a closed this pull request 3 年之前
This pull request cannot be reopened because the branch was deleted.
You can also view command line instructions.

Step 1:

From your project repository, check out a new branch and test the changes.
git checkout -b DearRude/force-lang master
git pull origin DearRude/force-lang

Step 2:

Merge the changes and update on Forgejo.
git checkout master
git merge --no-ff DearRude/force-lang
git push origin master
登入 才能加入這對話。
No reviewers
未選擇里程碑
No Assignees
2 參與者
訊息
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Plume/Plume#792
Loading…
尚未有任何內容