skyrim-community-shaders icon indicating copy to clipboard operation
skyrim-community-shaders copied to clipboard

feat: support localization (#309)

Open Sieluna opened this issue 11 months ago • 26 comments
trafficstars

PR Summary:

  1. Translation files need to be in UTF-16 LE with BOM format.
  2. 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.

Sieluna avatar Dec 15 '24 09:12 Sieluna

Have you tested it? Because I don't think our font has CJK glyphs.

Pentalimbed avatar Dec 15 '24 12:12 Pentalimbed

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

Sieluna avatar Dec 15 '24 12:12 Sieluna

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.

Pentalimbed avatar Dec 15 '24 12:12 Pentalimbed

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.

Sieluna avatar Dec 15 '24 13:12 Sieluna

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.

This sounds like it needs to be part of the build system? Though I guess we'd only rerun when someone sees missing characters

doodlum avatar Dec 16 '24 04:12 doodlum

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.

CommunityShaders - esl.zip

Sieluna avatar Dec 18 '24 08:12 Sieluna

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

Sieluna avatar Dec 18 '24 23:12 Sieluna

I still haven't got the answer of whether the Japanese translation is verified by any actual Japanese speaker.

Pentalimbed avatar Dec 18 '24 23:12 Pentalimbed

I still haven't got the answer of whether the Japanese translation is verified by any actual Japanese speaker.

no

Sieluna avatar Dec 19 '24 00:12 Sieluna

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.

alandtse avatar Dec 23 '24 18:12 alandtse

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.

Sieluna avatar Dec 25 '24 06:12 Sieluna

Lokalise is free for open source projects. As are other platforms. It's just a matter of doodlum choosing and setting it up.

alandtse avatar Dec 25 '24 09:12 alandtse

https://github.com/user-attachments/assets/2b382875-e96c-44b1-a62d-9020f98b4f09

Sieluna avatar Dec 25 '24 16:12 Sieluna

@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

Screenshot 2024-12-26 000649

Screenshot 2024-12-26 004422

Sieluna avatar Dec 25 '24 23:12 Sieluna

I use it in another open source project. You just set a ci to pull the latest translations. No need for PRs.

alandtse avatar Dec 25 '24 23:12 alandtse

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

Sieluna avatar Dec 25 '24 23:12 Sieluna

A cronjob PR is fine. Or https://github.com/alandtse/alexa_media_player/blob/dev/.github%2Fworkflows%2Fsemantic_release.yml#L19-L36.

alandtse avatar Dec 26 '24 01:12 alandtse

@doodlum @alandtse @Pentalimbed I think the workflow is now stable and ready for review. Build status: Status

Artifact: Release (Support Spanish & Chinese only)

Sieluna avatar Dec 26 '24 10:12 Sieluna

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.

alandtse avatar Dec 26 '24 17:12 alandtse

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:

  1. You only need to register a Lokalise account.
  2. 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). image image
  3. 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 image
  4. Then go to Lokalise for translation, come back, and build it. image

Sieluna avatar Dec 26 '24 18:12 Sieluna

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.

doodlum avatar Jan 13 '25 16:01 doodlum

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 avatar Jan 14 '25 00:01 Sieluna

@Sieluna I'm back if you have the time to handle the conflicts, we can get this merged.

alandtse avatar May 19 '25 02:05 alandtse

@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?

alandtse avatar Jun 24 '25 21:06 alandtse

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 Menu class, 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.

❤️ Share
🪧 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 @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in 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 pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere 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.

coderabbitai[bot] avatar Jul 14 '25 16:07 coderabbitai[bot]

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

github-actions[bot] avatar Jul 14 '25 16:07 github-actions[bot]