Fix issue #642, frontend not in english if the user language does not exist #648

Слито
requiem958 слито 2 коммит(ов) из issue-frontend-language в master 5 лет назад
requiem958 прокомментировал(а) 5 лет назад (Перенесено из github.com)

Fix #642

Iterate over catalogs to find the english index and then use it instead of 0.

Fix [#642](https://github.com/Plume-org/Plume/issues/642) Iterate over catalogs to find the english index and then use it instead of 0.
codecov[bot] прокомментировал(а) 5 лет назад (Перенесено из github.com)

Codecov Report

Merging #648 into master will increase coverage by 0.23%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #648      +/-   ##
==========================================
+ Coverage   35.11%   35.35%   +0.23%     
==========================================
  Files          68       68              
  Lines        7943     7915      -28     
  Branches     1889     1894       +5     
==========================================
+ Hits         2789     2798       +9     
+ Misses       4374     4341      -33     
+ Partials      780      776       -4
# [Codecov](https://codecov.io/gh/Plume-org/Plume/pull/648?src=pr&el=h1) Report > Merging [#648](https://codecov.io/gh/Plume-org/Plume/pull/648?src=pr&el=desc) into [master](https://codecov.io/gh/Plume-org/Plume/commit/28fb50438e53019d5bda97e3b2532e5831096c9e?src=pr&el=desc) will **increase** coverage by `0.23%`. > The diff coverage is `n/a`. ```diff @@ Coverage Diff @@ ## master #648 +/- ## ========================================== + Coverage 35.11% 35.35% +0.23% ========================================== Files 68 68 Lines 7943 7915 -28 Branches 1889 1894 +5 ========================================== + Hits 2789 2798 +9 + Misses 4374 4341 -33 + Partials 780 776 -4 ```
codecov[bot] прокомментировал(а) 5 лет назад (Перенесено из github.com)

Codecov Report

Merging #648 into master will increase coverage by 0.23%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #648      +/-   ##
==========================================
+ Coverage   35.11%   35.35%   +0.23%     
==========================================
  Files          68       68              
  Lines        7943     7915      -28     
  Branches     1889     1894       +5     
==========================================
+ Hits         2789     2798       +9     
+ Misses       4374     4341      -33     
+ Partials      780      776       -4
# [Codecov](https://codecov.io/gh/Plume-org/Plume/pull/648?src=pr&el=h1) Report > Merging [#648](https://codecov.io/gh/Plume-org/Plume/pull/648?src=pr&el=desc) into [master](https://codecov.io/gh/Plume-org/Plume/commit/28fb50438e53019d5bda97e3b2532e5831096c9e?src=pr&el=desc) will **increase** coverage by `0.23%`. > The diff coverage is `n/a`. ```diff @@ Coverage Diff @@ ## master #648 +/- ## ========================================== + Coverage 35.11% 35.35% +0.23% ========================================== Files 68 68 Lines 7943 7915 -28 Branches 1889 1894 +5 ========================================== + Hits 2789 2798 +9 + Misses 4374 4341 -33 + Partials 780 776 -4 ```
igalic (Перенесено из github.com) одобрил(а) эти изменения 5 лет назад
igalic (Перенесено из github.com) оставил комментарий

please ignore my rambling

please ignore my rambling
@ -47,2 +47,4 @@
let lang = js! { return navigator.language }.into_string().unwrap();
let lang = lang.splitn(2, '-').next().unwrap_or("en");
let english_position = catalogs
igalic (Перенесено из github.com) прокомментировал(а) 5 лет назад

this should be either a (cached?) constant, or a (cached?) config value

this should be either a (cached?) constant, or a (cached?) config value
@ -49,0 +50,4 @@
let english_position = catalogs
.iter()
.position(|(language_code, _)| *language_code == "en")
.unwrap();
igalic (Перенесено из github.com) прокомментировал(а) 5 лет назад

while i understand that this is a simple operation, i don't think we need to do it every time

while i understand that this is a simple operation, i don't think we need to do it every time
igalic (Перенесено из github.com) прокомментировал(а) 5 лет назад

actually, never mind, this is an operation that's only dealing with things known at compile time

the optimiser will probably inline this as a constant literal

actually, never mind, this is an operation that's only dealing with things known at compile time the optimiser will probably inline this as a constant literal
requiem958 (Перенесено из github.com) рассмотрел(а) изменения 5 лет назад
@ -47,2 +47,4 @@
let lang = js! { return navigator.language }.into_string().unwrap();
let lang = lang.splitn(2, '-').next().unwrap_or("en");
let english_position = catalogs
requiem958 (Перенесено из github.com) прокомментировал(а) 5 лет назад

It should be a constant yes, but the rust doc of constant says :

Constants can be set only to a constant expression and not to the result of a function call or any other value that will be computed at runtime.

So i thought the keyword const was forbidden in this case.

It should be a constant yes, but the rust doc of constant says : > Constants can be set only to a constant expression and not to the result of a function call or any other value that will be computed at runtime. So i thought the keyword const was forbidden in this case.
trinity-1686a рассмотрел(а) изменения 5 лет назад
@ -47,2 +47,4 @@
let lang = js! { return navigator.language }.into_string().unwrap();
let lang = lang.splitn(2, '-').next().unwrap_or("en");
let english_position = catalogs
trinity-1686a прокомментировал(а) 5 лет назад
Владелец

All this is in a lazy_static! call, so the result will be evaluated only one time, the first time CATALOG is accessed. The only thing it's not is cached between two different page loading, but that's not necessary imo

All this is in a lazy_static! call, so the result will be evaluated only one time, the first time CATALOG is accessed. The only thing it's not is cached between two different page loading, but that's not necessary imo

Рецензенты

Запрос на слияние был объединен как 935d331e97.
Вы также можете просмотреть инструкции командной строки.

Шаг 1:

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

Шаг 2:

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

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

Зависимости

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

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