libretro / gambatte-libretro

Hard fork of Gambatte to the libretro API.
http://sourceforge.net/projects/gambatte/
GNU General Public License v2.0
103 stars 78 forks source link

Convert core options into translation friendly form #196

Closed DisasterMo closed 2 years ago

DisasterMo commented 2 years ago

The Problem

The current state of core options is very translation unfriendly - the only way to add translations is by copying the entire option_defs_us array from libretro_core_options.h to libretro_core_options_intl.h and add each translation into place manually.

There exists no easy way to upload the texts to crowdin and updating the translations is just a pain.

Suggested Solution

In this PR I attempt to rectify this, even though a little naively: by converting the handling of core options into a form similar to how it is done in RetroArch - by utilising hash keys to fetch the actual string via the msg_hash_to_str() function from a msg_hash file corresponding to the current user language. Scripts for converting such msg_hash files into jsons for uploading to crowdin already exist and would need to be modified only slightly for compatibility with core options.

This here is a proof of concept for that idea and my scripts from libretro/RetroArch#12772.

Reviewers

@jdgleaver, since they just finished up the v2 update (thank you for your hard work!).

lgtm-com[bot] commented 2 years ago

This pull request introduces 1 alert when merging bd133bc7b465a4a8e9cb344e676b249482891fd6 into 2127f25d9b4970371d7b312e74cc9e64f13e6f7c - view on LGTM.com

new alerts:

DisasterMo commented 2 years ago

Okay, new approach! This one sets up 2 GitHub actions designed to

  1. extract any source texts from libretro_core_options.h every time that file is changed
  2. reconstruct libretro_core_options_intl.h every time something within libgambatte/libretro/intl/ is changed

The purpose of this is to enable periodic source/translations sync via Crowdin's GitHub integration option. Once this integration is set up, the process will run almost entirely automatically:

  1. changes to libretro_core_options.h will also result in the first action creating/updating the repo's source text .json
  2. Crowdin will periodically fetch that source file & create a PR with any new translations
  3. once that PR is merged, it obviously changes files within the intl folder, so the second GitHub action kicks in, reconstructing libretro_core_options_intl.h on the basis of these new translation files
  4. new translations acquired! (== profit!)