diff --git a/README.md b/README.md index 0bad25c0..464a4bd3 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,6 @@ Don't like the default white buttons and text? ModernZ is fully customizable! Ch See the [Color Customization](docs/USER_OPTS.md#colors) section in the configuration guide for details on how to customize colors and buttons. - ## Installation 1. **Copy Files** @@ -63,8 +62,8 @@ See the [Color Customization](docs/USER_OPTS.md#colors) section in the configura ├── modernz.lua └── thumbfast.lua (optional) ``` -> [!TIP] -> Need more details on MPV file locations? Check the [MPV manual](https://mpv.io/manual/master/#files). + > [!TIP] + > Need more details on MPV file locations? Check the [MPV manual](https://mpv.io/manual/master/#files). ## Configuration @@ -130,31 +129,42 @@ https://github.com/user-attachments/assets/188992ba-1ad8-4d71-a96c-44c3c99df4e0 ## Translations -ModernZ is in English by default, but it's easy to add translations. Just edit the local language table in `modernz.lua`. - -Example of adding/modifying translations in `modernz.lua`: - -```lua -local language = { - ["en"] = { - welcome = "Drop files or URLs to play here", - off = "OFF", - na = "n/a", - -- ... other strings - }, - ["zh"] = { - welcome = "{\\fs24\\1c&H0&\\1c&HFFFFFF&}将文件或URL放在这里播放", - off = "关闭", - na = "n/a", - -- ... other strings - } -} -``` +ModernZ is currently available in English, but you can easily switch it to your preferred language! Here's how: + +**1. Download the locale pack:** + +Grab the [modernz-locale.lua](/modernz-locale.lua) file from this repository. This file holds translations for various languages. + +**2. Add the locales to MPV:** + +Copy the downloaded `modernz-locale.lua` file to your MPV's `/scripts` folder. + +**3. Choose our language:** + +There are two ways to set your preferred language: + +- **Recommended:** Use the `modernz.conf` file + + ```ini + # Example configuration in modernz.conf + language = "zh" # Set language to Simplified Chinese + ``` + +- **Alternative:** Edit the `modernz.lua` script + + Open `modernz.lua` and find the `user_opts` section near the beginning. Change the `language` value to your preferred code: + + ```lua + local user_opts = { + -- General + language = "en", -- Change this to your preferred language code + ... + } + ``` -For complete translation documentation, available languages, and contribution guidelines, see [TRANSLATIONS.md](docs/TRANSLATIONS.md). +**Need More Info?** -**Q: Why aren't all translations included by default?** -A: They were, once. It would be difficult for me to maintain it accurately for many languages. This way, users have the option to localize it without flooding the OSC file with language listings. +For a complete list of available languages, contribution guidelines, and in-depth translation documentation, head over to the [TRANSLATIONS.md](docs/TRANSLATIONS.md). ## Extras diff --git a/docs/TRANSLATIONS.md b/docs/TRANSLATIONS.md index 860e20ff..ec6b799a 100644 --- a/docs/TRANSLATIONS.md +++ b/docs/TRANSLATIONS.md @@ -1,306 +1,97 @@ # ModernZ Translations Guide -This guide explains how to use, modify, and add translations for the ModernZ OSC interface. +This guide provides everything you need to use, modify, and add translations for the ModernZ OSC interface. ## Table of Contents - [Quick Start](#quick-start) - [Available Languages](#available-languages) - [Adding a New Language](#adding-a-new-language) -- [Modifying Existing Translations](#modifying-existing-translations) +- [Updating Existing Translations](#updating-existing-translations) - [Translation Keys Reference](#translation-keys-reference) - [Contributing Translations](#contributing-translations) ## Quick Start -1. Open `modernz.lua` in your text editor -2. Locate the `language` table near the top of the file -3. Add or modify translations using the format: +To get started with translations: + +1. **Locate the translation file:** Open the `modernz-locale.lua` file from the repository (typically found at [`../modernz-locale.lua`](../modernz-locale.lua)). +2. **Edit Translations:** Use the following format to add or modify translations: ```lua - local language = { - ["language-code"] = { - welcome = "Your translation", - off = "Your translation", - -- ... other strings - }, + ["language-code"] = { + welcome = "Your translation", + off = "Your translation", + -- ... other strings } ``` -## Available Languages - -
- French (fr) - -> In `modernz.conf` you must use `language=fr` for it to be active. - -```lua - ["fr"] = { - welcome = "{\\fs24\\1c&H0&\\1c&HFFFFFF&}Déposez des fichiers ou des URLs ici pour les lire", - off = "DÉSACTIVÉ", - na = "n/d", - none = "Aucun disponible", - video = "Vidéo", - audio = "Audio", - subtitle = "Sous-titre", - nosub = "Pas de sous-titres disponibles", - noaudio = "Pas de pistes audio disponibles", - track = " pistes:", - playlist = "Liste de lecture", - nolist = "Liste de lecture vide.", - chapter = "Chapitre", - nochapter = "Pas de chapitres.", - ontop = "Épingler la fenêtre", - ontopdisable = "Désépingler la fenêtre", - loopenable = "Activer la boucle", - loopdisable = "Désactiver la boucle", - screenshot = "Capture d'écran", - screenshotsaved = "Capture d'écran enregistrée", - statsinfo = "Information", - }, -``` - -
-
- German (de) - -> In `modernz.conf` you must use `language=de` for it to be active. - -```lua - ["de"] = { - welcome = "{\\fs24\\1c&H0&\\1c&HFFFFFF&}Dateien oder URLs hier ablegen, um sie abzuspielen", - off = "AUS", - na = "k.A.", - none = "Keine verfügbar", - video = "Video", - audio = "Audio", - subtitle = "Untertitel", - nosub = "Keine Untertitel verfügbar", - noaudio = "Keine Audiospuren verfügbar", - track = " Spuren:", - playlist = "Wiedergabeliste", - nolist = "Leere Wiedergabeliste.", - chapter = "Kapitel", - nochapter = "Keine Kapitel.", - ontop = "Fenster fixieren", - ontopdisable = "Fensterfixierung aufheben", - loopenable = "Schleifen aktivieren", - loopdisable = "Schleifen deaktivieren", - screenshot = "Screenshot", - screenshotsaved = "Screenshot gespeichert", - statsinfo = "Information", - }, -``` - -
-
- Spanish (es) - -> In `modernz.conf` you must use `language=es` for it to be active. - -```lua - ["es"] = { - welcome = "{\\fs24\\1c&H0&\\1c&HFFFFFF&}Suelta archivos o URLs aquí para reproducirlos", - off = "APAGADO", - na = "n/d", - none = "Ninguno disponible", - video = "Video", - audio = "Audio", - subtitle = "Subtítulo", - nosub = "No hay subtítulos disponibles", - noaudio = "No hay pistas de audio disponibles", - track = " pistas:", - playlist = "Lista de reproducción", - nolist = "Lista de reproducción vacía.", - chapter = "Capítulo", - nochapter = "No hay capítulos.", - ontop = "Fijar ventana", - ontopdisable = "Desfijar ventana", - loopenable = "Activar bucle", - loopdisable = "Desactivar bucle", - screenshot = "Captura de pantalla", - screenshotsaved = "Captura de pantalla guardada", - statsinfo = "Información", - }, -``` - -
-
- Polish (pl) - -> In `modernz.conf` you must use `language=pl` for it to be active. - -```lua - ["pl"] = { - welcome = "{\\fs24\\1c&H0&\\1c&HFFFFFF&}Upuść plik lub łącze URL do odtworzenia", - off = "WYŁ.", - na = "n/a", - none = "nic", - video = "Wideo", - audio = "Audio", - subtitle = "Napisy", - nosub = "Brak dostępnych napisów", - noaudio = "Brak dostępnych ścieżek dźwiękowych", - track = " ścieżki:", - playlist = "Lista odtwarzania", - nolist = "Lista odtwarzania pusta.", - chapter = "Rozdział", - nochapter = "Brak rozdziałów.", - ontop = "Przypnij okno do góry", - ontopdisable = "Odepnij okno od góry", - loopenable = "Włączenie zapętlenia", - loopdisable = "Wyłączenie zapętlenia", - screenshot = "Zrzut ekranu", - screenshotsaved = "Zrzut ekranu zapisany", - statsinfo = "Informacja", - }, -``` - -
-
- Japanese (jp) +- Replace `"language-code"` with your language code (e.g., "es" for Spanish). -> In `modernz.conf` you must use `language=jp` for it to be active. - -```lua - ["jp"] = { - welcome = "{\\fs24\\1c&H0&\\1c&HFFFFFF&}ファイルやURLのリンクをここにドロップすると再生されます", - off = "OFF", - na = "n/a", - none = "なし", - video = "ビデオ", - audio = "オーディオ", - subtitle = "サブタイトル", - nosub = "字幕はありません", - noaudio = "オーディオトラックはありません", - track = "トラック:", - playlist = "プレイリスト", - nolist = "空のプレイリスト.", - chapter = "チャプター", - nochapter = "利用可能なチャプターはありません.", - ontop = "ピンウィンドウをトップに表示", - ontopdisable = "ウィンドウを上からアンピンする", - loopenable = "ループON", - loopdisable = "ループOFF", - screenshot = "スクリーンショット", - screenshotsaved = "スクリーンショットが保存されました", - statsinfo = "情報", - }, -``` - -
-
- Simplified Chinese (zh) - -> In `modernz.conf` you must use `language=chs` for it to be active. +## Available Languages -```lua - ["zh"] = { - welcome = "{\\fs24\\1c&H0&\\1c&HFFFFFF&}将文件或URL放在这里播放", - off = "关闭", - na = "n/a", - none = "无数据", - video = "视频", - audio = "音频", - subtitle = "字幕", - nosub = "没有字幕", - noaudio = "不提供音轨", - track = ":", - playlist = "播放列表", - nolist = "无列表信息", - chapter = "章节", - nochapter = "无章节信息", - ontop = "启用窗口停留在顶层", - ontopdisable = "禁用停留在顶层的窗口", - loopenable = "启用循环功能", - loopdisable = "禁用循环功能", - screenshot = "截屏", - screenshotsaved = "截图已保存", - statsinfo = "信息", - }, -``` +ModernZ currently has translations for the following languages: -
-
- Arabic (ar) +- French (fr) +- German (de) +- Spanish (es) +- Polish (pl) +- Japanese (jp) +- Simplified Chinese (zh) +- Arabic (ar) -> In `modernz.conf` you must use `language=ar` for it to be active. +## Adding a New Language -```lua - ["ar"] = { - welcome = "{\\fs24\\1c&H0&\\1c&HFFFFFF&}أسقط الملفات أو الروابط هنا للتشغيل", - off = "إيقاف", - na = "غير متاح", - none = "غير متوفر", - video = "فيديو", - audio = "صوت", - subtitle = "الترجمة", - nosub = "لا توجد ترجمات", - noaudio = "لا توجد مسارات صوتية", - track = " مسارات:", - playlist = "قائمة التشغيل", - nolist = "قائمة التشغيل فارغة.", - chapter = "الفصل", - nochapter = "لا توجد فصول.", - ontop = "تثبيت النافذة", - ontopdisable = "إلغاء تثبيت النافذة", - loopenable = "تمكين التكرار", - loopdisable = "تعطيل التكرار", - screenshot = "لقطة شاشة", - screenshotsaved = "تم حفظ لقطة الشاشة", - statsinfo = "معلومات", - }, -``` +1. **Get the translation file**: If you haven't already, download the `modernz-locale.lua` file. +2. **Open the file**: Open `modernz-locale.lua` in a text editor. +3. **Choose a language code**: Pick a unique code representing your language (e.g., "it" for Italian). +4. **Copy an existing template**: Use an existing language section as a base. For example, use the English template: -
+ ```lua + ["en"] = { + welcome = "{\\fs24\\1c&H0&\\1c&HFFFFFF&}Drop files or URLs to play here", + off = "OFF", + na = "n/a", + none = "None available", + video = "Video", + audio = "Audio", + subtitle = "Subtitle", + nosub = "No subtitles available", + noaudio = "No audio tracks available", + track = " tracks:", + playlist = "Playlist", + nolist = "Empty playlist.", + chapter = "Chapter", + nochapter = "No chapters.", + ontop = "Pin window", + ontopdisable = "Unpin window", + loopenable = "Enable loop", + loopdisable = "Disable loop", + screenshot = "Screenshot", + screenshotsaved = "Screenshot saved", + statsinfo = "Information" + }, + ``` -## Adding a New Language +5. **Translate the strings**: Replace the English text with your translations, keeping the same keys. -1. Choose a language code (e.g., "es" for Spanish) -2. Copy the English template: + ```lua + ["es"] = { + welcome = "{\\fs24\\1c&H0&\\1c&HFFFFFF&}Suelta archivos o URLs aquí para reproducirlos", + off = "APAGADO", + na = "n/d", + -- ... translate other strings + }, + ``` -```lua -["en"] = { - welcome = "{\\fs24\\1c&H0&\\1c&HFFFFFF&}Drop files or URLs to play here", - off = "OFF", - na = "n/a", - none = "None available", - video = "Video", - audio = "Audio", - subtitle = "Subtitle", - nosub = "No subtitles available", - noaudio = "No audio tracks available", - track = " tracks:", - playlist = "Playlist", - nolist = "Empty playlist.", - chapter = "Chapter", - nochapter = "No chapters.", - ontop = "Pin window", - ontopdisable = "Unpin window", - loopenable = "Enable loop", - loopdisable = "Disable loop", - screenshot = "Screenshot", - screenshotsaved = "Screenshot saved", - statsinfo = "Information" -}, -``` +## Updating existing translations -3. Add your translation with the new language code: +1. **Find your language**: Locate the section for your language in `modernz-locale.lua`. -```lua -["es"] = { - welcome = "{\\fs24\\1c&H0&\\1c&HFFFFFF&}Suelta archivos o URLs aquí para reproducirlos", - off = "APAGADO", - na = "n/d", - -- ... translate other strings -}, -``` +2. **Update the strings**: ensuring you preserve any formatting codes. -## Modifying Existing Translations + (e.g., `{\\fs24\\1c&H0&\\1c&HFFFFFF&}`). -1. Find the language section you want to modify -2. Update the strings as needed -3. Keep any formatting codes (e.g., `{\\fs24\\1c&H0&\\1c&HFFFFFF&}`) -4. Test the changes by playing a video +3. **Test your changes**: Play a video to verify the translations work correctly. ## Translation Keys Reference @@ -322,13 +113,16 @@ This guide explains how to use, modify, and add translations for the ModernZ OSC | screenshotsaved | Screenshot confirmation | Status message | | statsinfo | Information label | Menu label | -## Contributing Translations +## Contributing If you'd like to share your translations with the community: -1. Fork the [ModernZ repository](https://github.com/Samillion/ModernZ) -2. Add your translations to the TRANSLATIONS.md file under the [Available Languages](#available-languages) section: - - Add a new collapsible section using the existing format - - Include the language code and configuration note - - Add your translation table in a code block -3. Submit a pull request +1. **Fork the repository**: Visit the ModernZ GitHub page (https://github.com/Samillion/ModernZ) and click "Fork" to create your own copy of the project. + +2. **Edit the** `modernz-locale.lua` **file** Add your translations to the file in your forked repository. + +3. **Submit a Pull Request** Create a pull request on GitHub to propose your changes for review and integration. + +--- + +Thanks for contributing ❤️ Every translation helps make the project better! diff --git a/modernz-locale.lua b/modernz-locale.lua new file mode 100644 index 00000000..016220a1 --- /dev/null +++ b/modernz-locale.lua @@ -0,0 +1,169 @@ +return { + ["fr"] = { + welcome = "{\\fs24\\1c&H0&\\1c&HFFFFFF&}Déposez des fichiers ou des URLs ici pour les lire", + off = "DÉSACTIVÉ", + na = "n/d", + none = "Aucun disponible", + video = "Vidéo", + audio = "Audio", + subtitle = "Sous-titre", + nosub = "Pas de sous-titres disponibles", + noaudio = "Pas de pistes audio disponibles", + track = " pistes:", + playlist = "Liste de lecture", + nolist = "Liste de lecture vide.", + chapter = "Chapitre", + nochapter = "Pas de chapitres.", + ontop = "Épingler la fenêtre", + ontopdisable = "Désépingler la fenêtre", + loopenable = "Activer la boucle", + loopdisable = "Désactiver la boucle", + screenshot = "Capture d'écran", + screenshotsaved = "Capture d'écran enregistrée", + statsinfo = "Information" + }, + + ["de"] = { + welcome = "{\\fs24\\1c&H0&\\1c&HFFFFFF&}Dateien oder URLs hier ablegen, um sie abzuspielen", + off = "AUS", + na = "k.A.", + none = "Keine verfügbar", + video = "Video", + audio = "Audio", + subtitle = "Untertitel", + nosub = "Keine Untertitel verfügbar", + noaudio = "Keine Audiospuren verfügbar", + track = " Spuren:", + playlist = "Wiedergabeliste", + nolist = "Leere Wiedergabeliste.", + chapter = "Kapitel", + nochapter = "Keine Kapitel.", + ontop = "Fenster fixieren", + ontopdisable = "Fensterfixierung aufheben", + loopenable = "Schleifen aktivieren", + loopdisable = "Schleifen deaktivieren", + screenshot = "Screenshot", + screenshotsaved = "Screenshot gespeichert", + statsinfo = "Information" + }, + + ["es"] = { + welcome = "{\\fs24\\1c&H0&\\1c&HFFFFFF&}Suelta archivos o URLs aquí para reproducirlos", + off = "APAGADO", + na = "n/d", + none = "Ninguno disponible", + video = "Video", + audio = "Audio", + subtitle = "Subtítulo", + nosub = "No hay subtítulos disponibles", + noaudio = "No hay pistas de audio disponibles", + track = " pistas:", + playlist = "Lista de reproducción", + nolist = "Lista de reproducción vacía.", + chapter = "Capítulo", + nochapter = "No hay capítulos.", + ontop = "Fijar ventana", + ontopdisable = "Desfijar ventana", + loopenable = "Activar bucle", + loopdisable = "Desactivar bucle", + screenshot = "Captura de pantalla", + screenshotsaved = "Captura de pantalla guardada", + statsinfo = "Información" + }, + + ["pl"] = { + welcome = "{\\fs24\\1c&H0&\\1c&HFFFFFF&}Upuść plik lub łącze URL do odtworzenia", + off = "WYŁ.", + na = "n/a", + none = "nic", + video = "Wideo", + audio = "Audio", + subtitle = "Napisy", + nosub = "Brak dostępnych napisów", + noaudio = "Brak dostępnych ścieżek dźwiękowych", + track = " ścieżki:", + playlist = "Lista odtwarzania", + nolist = "Lista odtwarzania pusta.", + chapter = "Rozdział", + nochapter = "Brak rozdziałów.", + ontop = "Przypnij okno do góry", + ontopdisable = "Odepnij okno od góry", + loopenable = "Włączenie zapętlenia", + loopdisable = "Wyłączenie zapętlenia", + screenshot = "Zrzut ekranu", + screenshotsaved = "Zrzut ekranu zapisany", + statsinfo = "Informacja" + }, + + ["jp"] = { + welcome = "{\\fs24\\1c&H0&\\1c&HFFFFFF&}ファイルやURLのリンクをここにドロップすると再生されます", + off = "OFF", + na = "n/a", + none = "なし", + video = "ビデオ", + audio = "オーディオ", + subtitle = "サブタイトル", + nosub = "字幕はありません", + noaudio = "オーディオトラックはありません", + track = "トラック:", + playlist = "プレイリスト", + nolist = "空のプレイリスト.", + chapter = "チャプター", + nochapter = "利用可能なチャプターはありません.", + ontop = "ピンウィンドウをトップに表示", + ontopdisable = "ウィンドウを上からアンピンする", + loopenable = "ループON", + loopdisable = "ループOFF", + screenshot = "スクリーンショット", + screenshotsaved = "スクリーンショットが保存されました", + statsinfo = "情報" + }, + + ["zh"] = { + welcome = "{\\fs24\\1c&H0&\\1c&HFFFFFF&}将文件或URL放在这里播放", + off = "关闭", + na = "n/a", + none = "无数据", + video = "视频", + audio = "音频", + subtitle = "字幕", + nosub = "没有字幕", + noaudio = "不提供音轨", + track = ":", + playlist = "播放列表", + nolist = "无列表信息", + chapter = "章节", + nochapter = "无章节信息", + ontop = "启用窗口停留在顶层", + ontopdisable = "禁用停留在顶层的窗口", + loopenable = "启用循环功能", + loopdisable = "禁用循环功能", + screenshot = "截屏", + screenshotsaved = "截图已保存", + statsinfo = "信息" + }, + + ["ar"] = { + welcome = "{\\fs24\\1c&H0&\\1c&HFFFFFF&}أسقط الملفات أو الروابط هنا للتشغيل", + off = "إيقاف", + na = "غير متاح", + none = "غير متوفر", + video = "فيديو", + audio = "صوت", + subtitle = "الترجمة", + nosub = "لا توجد ترجمات", + noaudio = "لا توجد مسارات صوتية", + track = " مسارات:", + playlist = "قائمة التشغيل", + nolist = "قائمة التشغيل فارغة.", + chapter = "الفصل", + nochapter = "لا توجد فصول.", + ontop = "تثبيت النافذة", + ontopdisable = "إلغاء تثبيت النافذة", + loopenable = "تمكين التكرار", + loopdisable = "تعطيل التكرار", + screenshot = "لقطة شاشة", + screenshotsaved = "تم حفظ لقطة الشاشة", + statsinfo = "معلومات" + } +} diff --git a/modernz.lua b/modernz.lua index 9f96131d..78557af7 100644 --- a/modernz.lua +++ b/modernz.lua @@ -188,38 +188,57 @@ local icons = { } } --- Localization --- To add more languages: --- https://github.com/Samillion/ModernZ#osc-language +--- Localization local language = { ["en"] = { - welcome = "{\\fs24\\1c&H0&\\1c&HFFFFFF&}Drop files or URLs to play here", - off = "OFF", - na = "n/a", - none = "None available", - video = "Video", - audio = "Audio", - subtitle = "Subtitle", - nosub = "No subtitles available", - noaudio = "No audio tracks available", - track = " tracks:", - playlist = "Playlist", - nolist = "Empty playlist.", - chapter = "Chapter", - nochapter = "No chapters.", - ontop = "Pin window", - ontopdisable = "Unpin window", - loopenable = "Enable loop", - loopdisable = "Disable loop", - screenshot = "Screenshot", - screenshotsaved = "Screenshot saved", - statsinfo = "Information", + welcome = "{\\fs24\\1c&H0&\\1c&HFFFFFF&}Drop files or URLs to play here", + off = "OFF", + na = "n/a", + none = "None available", + video = "Video", + audio = "Audio", + subtitle = "Subtitle", + nosub = "No subtitles available", + noaudio = "No audio tracks available", + track = " tracks:", + playlist = "Playlist", + nolist = "Empty playlist.", + chapter = "Chapter", + nochapter = "No chapters.", + ontop = "Pin window", + ontopdisable = "Unpin window", + loopenable = "Enable loop", + loopdisable = "Disable loop", + screenshot = "Screenshot", + screenshotsaved = "Screenshot saved", + statsinfo = "Information", }, } +-- Load external locales if available +local locale_file = mp.find_config_file('scripts/modernz-locale.lua') +if locale_file then + local success, external = pcall(function() + return loadfile(locale_file)() + end) + + if success and external then + -- Merge external locales + for lang, strings in pairs(external) do + language[lang] = strings + -- Fill in any missing locales with English + for key, value in pairs(language["en"]) do + if strings[key] == nil then + strings[key] = value + end + end + end + end +end + local texts local function set_osc_texts() - texts = language[user_opts.language] + texts = language[user_opts.language] or language["en"] end local thumbfast = {