Move localized number formatting methods to TranslationServer
Co-Authored-By: Pāvels Nadtočajevs <7645683+bruvzg@users.noreply.github.com>
This commit is contained in:
@ -34,6 +34,7 @@
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/os/keyboard.h"
|
||||
#include "core/string/string_builder.h"
|
||||
#include "core/string/translation_server.h"
|
||||
#include "core/string/ustring.h"
|
||||
#include "scene/theme/theme_db.h"
|
||||
|
||||
@ -1545,7 +1546,7 @@ void CodeEdit::_line_number_draw_callback(int p_line, int p_gutter, const Rect2
|
||||
const String &lang = _get_locale();
|
||||
String fc = String::num_int64(p_line + 1).lpad(line_number_digits, line_number_padding);
|
||||
if (is_localizing_numeral_system()) {
|
||||
fc = TS->format_number(fc, lang);
|
||||
fc = TranslationServer::get_singleton()->format_number(fc, lang);
|
||||
}
|
||||
|
||||
text_rid = TS->create_shaped_text();
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
|
||||
#include "progress_bar.h"
|
||||
|
||||
#include "core/string/translation_server.h"
|
||||
#include "scene/resources/text_line.h"
|
||||
#include "scene/theme/theme_db.h"
|
||||
|
||||
@ -168,7 +169,7 @@ void ProgressBar::_notification(int p_what) {
|
||||
|
||||
if (is_localizing_numeral_system()) {
|
||||
const String &lang = _get_locale();
|
||||
txt = TS->format_number(txt, lang) + TS->percent_sign(lang);
|
||||
txt = TranslationServer::get_singleton()->format_number(txt, lang) + TranslationServer::get_singleton()->get_percent_sign(lang);
|
||||
} else {
|
||||
txt += String("%");
|
||||
}
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
#include "core/math/math_defs.h"
|
||||
#include "core/os/keyboard.h"
|
||||
#include "core/os/os.h"
|
||||
#include "core/string/translation_server.h"
|
||||
#include "scene/gui/label.h"
|
||||
#include "scene/gui/rich_text_effect.h"
|
||||
#include "scene/main/timer.h"
|
||||
@ -252,7 +253,7 @@ String RichTextLabel::_get_prefix(Item *p_item, const Vector<int> &p_list_index,
|
||||
if (p_list_items[i]->list_type == LIST_NUMBERS) {
|
||||
segment = itos(p_list_index[i]);
|
||||
if (is_localizing_numeral_system()) {
|
||||
segment = TS->format_number(segment, _find_language(p_item));
|
||||
segment = TranslationServer::get_singleton()->format_number(segment, _find_language(p_item));
|
||||
}
|
||||
segments++;
|
||||
} else if (p_list_items[i]->list_type == LIST_LETTERS) {
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
|
||||
#include "core/input/input.h"
|
||||
#include "core/math/expression.h"
|
||||
#include "core/string/translation_server.h"
|
||||
#include "scene/theme/theme_db.h"
|
||||
|
||||
void SpinBoxLineEdit::_accessibility_action_inc(const Variant &p_data) {
|
||||
@ -88,7 +89,7 @@ void SpinBox::_update_text(bool p_only_update_if_value_changed) {
|
||||
double step = get_step();
|
||||
String value = String::num(get_value(), Math::range_step_decimals(step));
|
||||
if (is_localizing_numeral_system()) {
|
||||
value = TS->format_number(value, _get_locale());
|
||||
value = TranslationServer::get_singleton()->format_number(value, _get_locale());
|
||||
}
|
||||
|
||||
if (p_only_update_if_value_changed && value == last_text_value) {
|
||||
@ -139,7 +140,7 @@ void SpinBox::_text_submitted(const String &p_string) {
|
||||
|
||||
const String &lang = _get_locale();
|
||||
text = text.replace_char(';', ',');
|
||||
text = TS->parse_number(text, lang);
|
||||
text = TranslationServer::get_singleton()->parse_number(text, lang);
|
||||
// Ignore the prefix and suffix in the expression.
|
||||
text = text.trim_prefix(prefix + " ").trim_suffix(" " + suffix);
|
||||
|
||||
@ -148,7 +149,7 @@ void SpinBox::_text_submitted(const String &p_string) {
|
||||
if (err != OK) {
|
||||
// If the expression failed try without converting commas to dots - they might have been for parameter separation.
|
||||
text = p_string;
|
||||
text = TS->parse_number(text, lang);
|
||||
text = TranslationServer::get_singleton()->parse_number(text, lang);
|
||||
text = text.trim_prefix(prefix + " ").trim_suffix(" " + suffix);
|
||||
|
||||
err = expr->parse(text);
|
||||
|
||||
Reference in New Issue
Block a user