mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Merge pull request #108862 from timothyqiu/plural-rules
Move context and plural support to `Translation`
This commit is contained in:
commit
49219de402
15 changed files with 678 additions and 478 deletions
|
|
@ -31,7 +31,7 @@
|
|||
#include "translation_loader_po.h"
|
||||
|
||||
#include "core/io/file_access.h"
|
||||
#include "core/string/translation_po.h"
|
||||
#include "core/string/translation.h"
|
||||
|
||||
Ref<Resource> TranslationLoaderPO::load_translation(Ref<FileAccess> f, Error *r_error) {
|
||||
if (r_error) {
|
||||
|
|
@ -39,7 +39,8 @@ Ref<Resource> TranslationLoaderPO::load_translation(Ref<FileAccess> f, Error *r_
|
|||
}
|
||||
|
||||
const String path = f->get_path();
|
||||
Ref<TranslationPO> translation = Ref<TranslationPO>(memnew(TranslationPO));
|
||||
Ref<Translation> translation;
|
||||
translation.instantiate();
|
||||
String config;
|
||||
|
||||
uint32_t magic = f->get_32();
|
||||
|
|
@ -112,7 +113,7 @@ Ref<Resource> TranslationLoaderPO::load_translation(Ref<FileAccess> f, Error *r_
|
|||
int p_start = config.find("Plural-Forms");
|
||||
if (p_start != -1) {
|
||||
int p_end = config.find_char('\n', p_start);
|
||||
translation->set_plural_rule(config.substr(p_start, p_end - p_start));
|
||||
translation->set_plural_rules_override(config.substr(p_start, p_end - p_start));
|
||||
}
|
||||
} else {
|
||||
uint32_t str_start = 0;
|
||||
|
|
@ -228,8 +229,8 @@ Ref<Resource> TranslationLoaderPO::load_translation(Ref<FileAccess> f, Error *r_
|
|||
int p_start = config.find("Plural-Forms");
|
||||
if (p_start != -1) {
|
||||
int p_end = config.find_char('\n', p_start);
|
||||
translation->set_plural_rule(config.substr(p_start, p_end - p_start));
|
||||
plural_forms = translation->get_plural_forms();
|
||||
translation->set_plural_rules_override(config.substr(p_start, p_end - p_start));
|
||||
plural_forms = translation->get_nplurals();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
|
||||
#include "core/io/file_access.h"
|
||||
#include "core/io/resource_loader.h"
|
||||
#include "core/string/translation.h"
|
||||
|
||||
class TranslationLoaderPO : public ResourceFormatLoader {
|
||||
GDSOFTCLASS(TranslationLoaderPO, ResourceFormatLoader);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue