Skip to content

Conversation

@rainjke
Copy link
Collaborator

@rainjke rainjke commented Dec 19, 2025

  • Implemented dynamic translation loading in i18n.js for better user experience.
  • Added English (en.json) and Russian (ru.json) translation files with extensive content for the application.
  • Created a mechanism to detect user language based on IP and browser settings.
  • Updated UI elements to utilize translation keys for multilingual support.
  • Included error handling for translation loading failures.

- Implemented dynamic translation loading in i18n.js for better user experience.
- Added English (en.json) and Russian (ru.json) translation files with extensive content for the application.
- Created a mechanism to detect user language based on IP and browser settings.
- Updated UI elements to utilize translation keys for multilingual support.
- Included error handling for translation loading failures.
@d-zaytsev
Copy link
Contributor

В проекте есть тесты для фронтенда (в CI это "full test"). В них в том числе иногда для проверок используется текст со страницы: https://github.com/mimi-net/miminet/blob/3f7c42e346ae0728c3da01b967b3ba3141be8394/front/tests/utils/locators.py#L206C1-L209C18. Мне кажется нужно проверить, не ломает ли локализация эти тесты (CI не прошёл, так что возможно что ломает).

Ещё круто было бы написать несколько фронтенд-тестов чисто на эту новую фичу. Чтобы MiminetTester попереключал язык туда-сюда и по странице побегал


async function detectLanguageByIP() {
try {
const response = await fetch('https://ipapi.co/json/');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А по-другому никак нельзя узнать IP?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно через язык браузера, это тоже предусмотрено, если это как то мешает или подвергается сомнению, можно вырезать и оставить только через определение языка через язык браузера. В любом случае есть локал сторедж и если пользователь зайдет и поставит английский, то английский останется, тут уже на Ваш вкус и цвет.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мне просто кажется странным сторонний сервис использовать. Как будто языка браузера + тумблера для переключения языка достаточно должно быть. Но может я не прав...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это было не мое пожелание)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А чьё?)

Каждый сторонний сервис - это потенциальная проблема недоступности нашего сервиса.
Предлагаю найти IP-адреса и сохранить их локально.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вы меня сами попросили об этом =(

if (typeof window !== 'undefined') {
window.translations = translations;
}
console.log(`Translations for ${lang} loaded.`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Наверное убрать лучше, либо сделать только для DEBUG

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

window.translations = translations; — оставляем. Это нужно для работы getTranslation() и используется в config.js.
console.log — лучше сделать условным через DEBUG-флаг. Вариант:
const DEBUG = typeof window !== 'undefined' && window.I18N_DEBUG === true;
if (DEBUG) { console.log(Translations for ${lang} loaded.);}
Так логи будут только при window.I18N_DEBUG = true в консоли браузера.
Альтернатива — убрать console.log совсем, если он не нужен.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, я про console.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants