-
Notifications
You must be signed in to change notification settings - Fork 41
Add internationalization support with English and Russian translations #382
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
base: main
Are you sure you want to change the base?
Conversation
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.
|
В проекте есть тесты для фронтенда (в CI это "full test"). В них в том числе иногда для проверок используется текст со страницы: https://github.com/mimi-net/miminet/blob/3f7c42e346ae0728c3da01b967b3ba3141be8394/front/tests/utils/locators.py#L206C1-L209C18. Мне кажется нужно проверить, не ломает ли локализация эти тесты (CI не прошёл, так что возможно что ломает). Ещё круто было бы написать несколько фронтенд-тестов чисто на эту новую фичу. Чтобы MiminetTester попереключал язык туда-сюда и по странице побегал |
front/src/static/js/i18n.js
Outdated
|
|
||
| async function detectLanguageByIP() { | ||
| try { | ||
| const response = await fetch('https://ipapi.co/json/'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А по-другому никак нельзя узнать IP?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно через язык браузера, это тоже предусмотрено, если это как то мешает или подвергается сомнению, можно вырезать и оставить только через определение языка через язык браузера. В любом случае есть локал сторедж и если пользователь зайдет и поставит английский, то английский останется, тут уже на Ваш вкус и цвет.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Мне просто кажется странным сторонний сервис использовать. Как будто языка браузера + тумблера для переключения языка достаточно должно быть. Но может я не прав...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это было не мое пожелание)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А чьё?)
Каждый сторонний сервис - это потенциальная проблема недоступности нашего сервиса.
Предлагаю найти IP-адреса и сохранить их локально.
There was a problem hiding this comment.
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.`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Наверное убрать лучше, либо сделать только для DEBUG
There was a problem hiding this comment.
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 совсем, если он не нужен.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Да, я про console.log
…s for translations