Commit Graph

31 Commits (cb1569345a6f17da08241e645ab03cb2e1b78d2f)

Author SHA1 Message Date
Haoyu Qiu 04ac5cbb89 Prevent the main locale from being set to an empty string 2025-11-18 10:07:35 +07:00
Thaddeus Crews 8327dfa215
Merge pull request #112092 from timothyqiu/ts-nums
Move localized number formatting methods to `TranslationServer`
2025-11-10 17:47:09 +07:00
Haoyu Qiu 72d437c030 Move localized number formatting methods to TranslationServer
Co-Authored-By: Pāvels Nadtočajevs <7645683+bruvzg@users.noreply.github.com>
2025-11-10 15:01:22 +07:00
Haoyu Qiu b8a8f8b35a Allow localizing the application name with project translations 2025-11-08 13:06:55 +07:00
Thaddeus Crews 20430236e7
Merge pull request #107999 from timothyqiu/translation-cleanup
Clean up editor translation related methods
2025-10-15 16:31:09 +07:00
Thaddeus Crews 49219de402
Merge pull request #108862 from timothyqiu/plural-rules
Move context and plural support to `Translation`
2025-10-15 16:31:07 +07:00
Thaddeus Crews 5935a32e32
Core: Cleanup headers in `core/config`
- `MainLoop` now forward-declared in `OS`
2025-10-06 09:20:56 +07:00
Haoyu Qiu e882e42e1b Add default plural rules
This makes the PO loader correctly handle the situation where the optional
`Plural-Forms` header field does not exist.

The `Translation` class and its subclasses always have access to valid plural
rules via `_get_plural_rules()`. Plural rules are prioritized:

1. `Translation.plural_rules_override`
2. `TranslationServer.get_plural_rules(locale)`
3. The English plural rules: `nplurals=2; plurals=(n != 1)`

Co-Authored-By: Pāvels Nadtočajevs <7645683+bruvzg@users.noreply.github.com>
2025-09-26 10:51:57 +07:00
Haoyu Qiu 3f03260a21 Cleanup editor translation related methods
- Unify logic for loading editor/property/doc/extractable translations.
- Replace legacy `TranslationServer` methods with translation domains for internal translations.
- Only pre-create editor/property/doc translation domains in editor builds.
- Prevent adding `null` translation.
- Fixes potential loading of duplicated editor translations.
- Add internal `has_translation_for_locale()` instead of calling `get_loaded_translations().has()`.
2025-09-18 20:27:09 +07:00
Adam Simpkins 21bc4b509f Remove an unnecessarily include of main/ code from core/
Code in core/ generally should not depend on code from main/

This include was added in #41100 in order to call
`Main::is_project_manager()`.  The `is_project_manager()` check was
later removed in #52742 but this include was never cleaned up.

This clean-up is related to #108429.
2025-07-09 19:09:11 +07:00
Thaddeus Crews e748514112
Merge pull request #105835 from bruvzg/edited_scene_direction
Improve edited scene layout direction detection.
2025-07-09 11:33:11 +07:00
Haoyu Qiu 8d93b6a54c Add translation preview in editor 2025-05-27 07:59:28 +07:00
Haoyu Qiu bbc6643e4c Remove translation loading logic that was never used 2025-05-12 19:05:20 +07:00
Pāvels Nadtočajevs 03048aa94a
Improve edited scene layout direction detection. 2025-04-28 07:57:26 +07:00
A Thousand Ships 889410dcda
Add `String::replace_char(s)` methods for performance and convenience 2025-04-10 13:08:45 +07:00
Pāvels Nadtočajevs c3921954f2
Fix editor layout direction change on translation change. 2025-03-27 17:35:21 +07:00
A Thousand Ships 466590d0ec
Use `get_slicec` instead of `get_slice` for single character splitters 2025-03-08 20:36:37 +07:00
Pāvels Nadtočajevs 9ae5f09c20 Fix editor UI showing empty string for unknown locales. 2025-02-13 08:07:26 +07:00
Pāvels Nadtočajevs e9fd760357 Use fallback locale from project settings instead of hardcoded "en" for TextServer. 2025-02-10 08:55:50 +07:00
Rémi Verschelde 88e81ee730
Fix various typos and code style issues 2024-11-28 17:40:42 +07:00
Dan Nicholson 6f4fadf65d Expose standardize_locale add_default param publicly
Comparing locales can have surprising outcomes since it standardizes
locales with defaults. For example, zh and zh_CN result in an exact
match since the defaults change them both to zh_Hans_CN. Expose the
add_default parameter publicly with a default of false so the fully
standardized locale can be inspected.
2024-11-21 16:50:31 +07:00
Thaddeus Crews ebf49317a2
Merge pull request #97923 from kisg/translation_server_siof_fix
Make TranslationServer singleton variable inline.
2024-11-12 12:13:01 +07:00
Dan Nicholson 2dd409fd70 Improve locale comparison
Since 9456454109, country specific locales are always preferred over
country-less locales even when the OS locale country doesn't match. For
example, running the Godot editor with locale es_ES will result in the
es_AR locale being chosen even though the es locale would be better.

The change happened because the score of the es_AR locale and the es
locale are the same when comparing to es_ES. Change this by parsing
locale strings into a Locale structure and decreasing the score when
script, country or variant are set in both but not matched. For the
es_ES case, this causes the es_AR score to be decreased since the
countries don't match. On the other hand, the es locale is not decreased
since it doesn't specify a country.
2024-11-12 06:06:50 +07:00
Haoyu Qiu acab2d6c1c Cache results for `TranslationServer.compare_locales()` 2024-10-16 20:54:56 +07:00
Gergely Kis 257633c354 Make TranslationServer singleton variable inline.
This change avoids the problem known as 'Static Initialization Order Fiasco' (SIOF).

See the following PR for more explanation: https://github.com/godotengine/godot/pull/94683

Co-authored-by: Gabor Koncz <gabor.koncz@migeran.com>
2024-10-07 13:47:42 +07:00
Haoyu Qiu cca54ba4db Move pseudolocalization into TranslationDomain
Also adds command-line option `--editor-pseudolocalization`
2024-09-21 18:28:12 +07:00
Haoyu Qiu 818acb4290 Make editor use translation domains
How editor plugins use this feature:
1. Pick a unique translation domain name.
2. `_enter_tree()`: load translations into that translation domain.
3. Call `set_translation_domain()` for its root UI node.
4. `_exit_tree()`: remove that translation domain.

Plugins can also set the translation domain to `godot.editor` for
nested nodes that should use editor translations. `EditorFileDialog`
automatically does this.
2024-09-17 13:09:44 +07:00
Haoyu Qiu 68d494e24e Add translation domain 2024-09-17 13:09:44 +07:00
rune-scape 0dde931bc9 StringName: Fix empty hash
+Fixed compat hashes
2024-09-09 13:30:02 +07:00
Pedro J. Estébanez cfb7443e26 TranslationServer: Add fast path for comparison of equal locales 2024-09-02 10:50:14 +07:00
Haoyu Qiu 7343dc3a5d Split TranslationServer into its own file 2024-08-15 15:00:47 +07:00