skyrim-community-shaders
skyrim-community-shaders copied to clipboard
feat: support localization (#309)
PR Summary:
- Translation files need to be in UTF-16 LE with BOM format.
- ESL file is required, if you don't want to wait for all forms to load: CommunityShaders - esl.zip
Summary by CodeRabbit
-
New Features
- Added support for UI localization and translation, enabling the interface to display text in multiple languages.
- Introduced a customizable font loader, allowing users to select font path and size for the menu.
-
Enhancements
- All UI text is now translatable, with English translation files provided for the Community Shaders mod interface.
- Improved translation handling with flexible placeholder substitution and formatting support.
-
Automation
- Integrated automated workflows for downloading and uploading translation files with Lokalise, including encoding conversions and artifact handling.
- Added retry logic and error handling for translation downloads to improve workflow reliability.
-
Chores
- Added static language mapping resources and updated repository attributes for consistent text encoding and line endings.
Have you tested it? Because I don't think our font has CJK glyphs.
Have you tested it? Because I don't think our font has CJK glyphs.
I'm temporarily using the default fonts that come with Windows.
I plan to write an additional Python script to bake the fonts later.
you can check the preview video here: https://github.com/doodlum/skyrim-community-shaders/issues/862
I plan to write an additional Python script to bake the fonts later.
Why additional python scripts tho? I think you can just use FontBuilder in ImGui and set the glyph ranges.
Why additional python scripts tho? I think you can just use in ImGui and set the glyph ranges.
FontBuilder
The main reason is that I don’t want to upload multiple font blob files, for example Source Han Sans, which, if bundled with Japanese, Korean, and Chinese characters, would total about 20MB. I aim to pre-bake the assets to include only the characters that are actually used.
Why additional python scripts tho? I think you can just use in ImGui and set the glyph ranges.
FontBuilderThe main reason is that I don’t want to upload multiple font blob files, for example Source Han Sans, which, if bundled with Japanese, Korean, and Chinese characters, would total about 20MB. I aim to pre-bake the assets to include only the characters that are actually used.
This sounds like it needs to be part of the build system? Though I guess we'd only rerun when someone sees missing characters
The code is expected to function without any significant issues. If you prefer to load the translation file immediately rather than relying on lazy loading, you can use a empty esp to assist SKSE load all assets at game startup.
Fixed txt was treated as binary. This means that the project must use the git version after this commit https://github.com/git/git/commit/aab2a1ae48ff65781a5379a01a4abb4f75e5641d
I still haven't got the answer of whether the Japanese translation is verified by any actual Japanese speaker.
I still haven't got the answer of whether the Japanese translation is verified by any actual Japanese speaker.
no
I don't think relying on PRs for the actual translations is effective as you require technical skills to upload them. We should use lokalise or some other tooling to automate the collection of translations to the community. I do not know if it'll support this tab separated format but we should investigate and get that infrastructure in place.
I don't think relying on PRs for the actual translations is effective as you require technical skills to upload them. We should use lokalise or some other tooling to automate the collection of translations to the community. I do not know if it'll support this tab separated format but we should investigate and get that infrastructure in place.
Good point, but using a third-party platform requires someone to cover the costs. Personally, I think it’s better to remove all translation files entirely, keep the MCM interface with the default English text, and let users manage translations themselves.
Update:
I’ve removed all translation-related content and kept the core only. This means the issue of managing translations via PRs no longer exists. If users want translations, they can download patches from Nexus or use an auto-translation mod like SSE-Auto-Translator.
Lokalise is free for open source projects. As are other platforms. It's just a matter of doodlum choosing and setting it up.
https://github.com/user-attachments/assets/2b382875-e96c-44b1-a62d-9020f98b4f09
@alandtse A sad news is that Lokalise requires you to submit translations via a PR (maybe everyday) https://github.com/Sieluna/skyrim-community-shaders/pull/1 . Currently, the only way to bypass the action steps is to avoid giving Lokalise PR permissions. actions
I use it in another open source project. You just set a ci to pull the latest translations. No need for PRs.
I use it in another open source project. You just set a ci to pull the latest translations. No need for PRs.
How can you achieve this? The action forces me to create a PR: https://github.com/lokalise/lokalise-pull-action/blob/b7587f118420378e8fd825a04ac27a70bf2778f0/action.yml#L123-L134
A cronjob PR is fine. Or https://github.com/alandtse/alexa_media_player/blob/dev/.github%2Fworkflows%2Fsemantic_release.yml#L19-L36.
@doodlum @alandtse @Pentalimbed I think the workflow is now stable and ready for review. Build status: Status
Artifact: Release (Support Spanish & Chinese only)
Can you provide a link to the lokalise project so we can join. We'll need at least one of us to be an admin of the project before we pull the PR.
Can you provide a link to the lokalise project so we can join. We'll need at least one of us to be an admin of the project before we pull the PR.
This requires your team to handle the configuration. My Lokalise account is currently in a free trial state and will expire soon. It's just for demonstration purposes.
The configuration is very simple:
- You only need to register a Lokalise account.
- Go to this address: https://github.com/doodlum/skyrim-community-shaders/settings/secrets/actions
Set up the Token and ID (repo or env both are fine).
- Go to the workflow and run Push to Lokalise (This is require when you add more translation key): https://github.com/doodlum/skyrim-community-shaders/actions/workflows/lokalise.yaml
- Then go to Lokalise for translation, come back, and build it.
I tried to link this up, I think some steps are missing? I'm not sure how to get the tokens. Maybe it is better if @alandtse or @FlayaN do this.
I tried to link this up, I think some steps are missing? I'm not sure how to get the tokens. Maybe it is better if @alandtse or @FlayaN do this.
See discord DM
@Sieluna I'm back if you have the time to handle the conflicts, we can get this merged.
@Sieluna we're taking another look in getting this in. We've had a lot more English strings though. How did you generate the initial list?
Walkthrough
This update introduces a comprehensive localization system. It adds translation utilities, a new English translation file, and workflow automation for synchronizing translations with Lokalise. The menu system is refactored to use localized strings, and font customization is supported. Supporting scripts and configuration files are included for encoding, mapping, and CI integration.
Changes
| File(s) | Change Summary |
|---|---|
| .gitattributes | Added line ending and encoding rules for translation files. |
| .github/workflows/build.yaml | Added translate job for pulling and converting Lokalise translations; integrated artifact into build. |
| .github/workflows/lokalise.yaml, .github/workflows/lokalise_download.mjs | Added workflow and script for pushing/pulling translations to/from Lokalise with encoding and mapping support. |
| .github/workflows/iso.json | Added static ISO language code mapping JSON file. |
| package/Interface/Translations/CommunityShaders_english.txt | Added English translation file for Community Shaders UI. |
| src/Menu.cpp, src/Menu.h | Refactored menu UI to use localization; added font loading and customization support. |
| src/Util.h | Included translation utilities header. |
| src/Utils/Translate.h, src/Utils/Translate.cpp | Added translation utility with formatting and user-defined literals for localization. |
| src/XSEPlugin.cpp | Added translation file parsing on data load. |
Sequence Diagram(s)
sequenceDiagram
participant User
participant Menu
participant TranslateUtil
participant TranslationFile
User->>Menu: Open UI
Menu->>TranslateUtil: Request localized string (key)
TranslateUtil->>TranslationFile: Lookup translation
TranslationFile-->>TranslateUtil: Return translation or key
TranslateUtil-->>Menu: Return localized string
Menu-->>User: Display localized UI
sequenceDiagram
participant GitHubActions
participant Lokalise
participant Repo
GitHubActions->>Lokalise: Download translations (translate job)
Lokalise-->>GitHubActions: Provide JSON files
GitHubActions->>GitHubActions: Convert JSON to UTF-16LE .txt
GitHubActions->>Repo: Upload translations artifact
GitHubActions->>Lokalise: Push updated translations (lokalise workflow)
Possibly related PRs
- #1272: Modifies font reload logic and font reload flag initialization in
Menuclass, related to font management. - #1247: Improves dynamic font size handling and adds UI controls for font size in
Menu, complementing font customization features.
Suggested reviewers
- doodlum
Poem
🐇
Translations bloom, the menu sings,
With fonts anew and language wings.
Workflows dance in UTF cheer,
Lokalise brings cultures near.
From English roots, the branches grow—
Now every bunny’s in the know!
🌍✨
📜 Recent review details
Configuration used: .coderabbit.yaml Review profile: CHILL Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 60058b877040913edda27d3fc5837d386b3c537e and bba85aa3a0584e18faf9b0337124dc91d025c858.
📒 Files selected for processing (1)
src/XSEPlugin.cpp(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/XSEPlugin.cpp
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build plugin and addons
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Explain this complex logic.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and explain its main purpose.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
Using provided base ref: 21f67064bbcfef2e1876674314135676ece62401 Using base ref: 21f67064bbcfef2e1876674314135676ece62401 Base commit date: 2025-07-13T20:59:08-07:00 (Sunday, July 13, 2025 08:59 PM)
Actionable Suggestions
- Hair Specular: Action required; Needs version bump to 1-0-1