Force interface language by config file #792

Закрыто
DearRude хочет влить 1 коммит(ов) из DearRude/force-lang в master
DearRude прокомментировал(а) 4 лет назад (Перенесено из 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 лет назад (Перенесено из 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 лет назад (Перенесено из 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.
trinity-1686a прокомментировал(а) 4 лет назад
Владелец

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
trinity-1686a прокомментировал(а) 3 лет назад
Владелец
> [I give up on this. Could not make it work...](https://github.com/Plume-org/Plume/pull/792#issuecomment-650167801)
trinity-1686a закрыл этот запрос на слияние 3 лет назад
Этот запрос на слияние не может быть открыт заново, потому что ветка была удалена.
Вы также можете просмотреть инструкции командной строки.

Шаг 1:

В репозитории вашего проекта посмотрите новую ветку и протестируйте изменения.
git checkout -b DearRude/force-lang master
git pull origin DearRude/force-lang

Шаг 2:

Объединить изменения и обновить на Forgejo.
git checkout master
git merge --no-ff DearRude/force-lang
git push origin master
Войдите, чтобы присоединиться к обсуждению.
Нет рецензентов
Нет этапа
Нет назначенных лиц
2 участников
Уведомления
Срок выполнения
Срок действия недействителен или находится за пределами допустимого диапазона. Пожалуйста, используйте формат 'гггг-мм-дд'.

Срок выполнения не установлен.

Зависимости

Зависимостей нет.

Reference: Plume/Plume#792
Загрузка…
Пока нет содержимого.