Localization (#15)

## Changes (escoria-core)
> Pending to do a PR to the core.
- Added `es` langcode with the corresponding flag image.
- Translated literals for `es`

## Changes (gymkhana)
-  Added `turno_cocina` localization csv.
- Proof of concept for tooltips & dialogs.

## Notes
- For tooltips just use the literals. Godot will automatically search for a translation key first.
- For ESC just use `translation_key:"Default text"`

## How to test
- In the option menu ES should be selectable.
- The `frontal` item in the inventory should have the tooltips and the `say` command translated in `en`,`fr` and `es`.

Reviewed-on: gymkhana/gymkhana#15
Co-authored-by: oier <oierbravo@gmail.com>
Co-committed-by: oier <oierbravo@gmail.com>
This commit is contained in:
2023-09-26 00:13:55 +02:00
committed by Oier Bravo
parent 6cbd466f76
commit 2d32f4b312
22 changed files with 241 additions and 72 deletions

View File

@@ -0,0 +1,118 @@
# `say_random player list_id lenght [offset]`
#
# Displays the specified string as dialog spoken by the player. This command
# blocks further event execution until the dialog has finished being 'said'
# (either as displayed text or as audible speech from a file).
#
# Global variables can be substituted into the text by wrapping the global
# name in braces.
# e.g. say player "I have {coin_count} coins remaining".
#
# **Parameters**
#
# - *player*: Global ID of the `ESCPlayer` or `ESCItem` object that is active.
# You can specify `current_player` in order to refer to the currently active
# player, e.g. in cases where multiple players are playable such as in games
# like Maniac Mansion or Day of the Tentacle.
# - *randomizer_list_id*: ID for the list of sentences.
# - *lenght*: lenght of the list.
# - *offset*: starting offset index of the list.
#
# Example: `say_random player random_list 4`
#
# @ESC
extends ESCBaseCommand
class_name SayRandomCommand
const CURRENT_PLAYER_KEYWORD = "CURRENT_PLAYER"
var rng: RandomNumberGenerator
# Constructor
func _init() -> void:
rng = RandomNumberGenerator.new()
# Return the descriptor of the arguments of this command
func configure() -> ESCCommandArgumentDescriptor:
return ESCCommandArgumentDescriptor.new(
3,
[TYPE_STRING, TYPE_STRING, TYPE_INT, TYPE_INT],
[
null,
null,
null,
0
],
[
true,
false,
false,
false
]
)
# Validate whether the given arguments match the command descriptor
func validate(arguments: Array):
if not .validate(arguments):
return false
if arguments[0].to_upper() != CURRENT_PLAYER_KEYWORD \
and not escoria.object_manager.has(arguments[0]):
escoria.logger.error(
self,
"[%s]: Invalid object: Object with global id %s not found."
% [get_command_name(), arguments[0]]
)
return false
return true
# Run the command
func run(command_params: Array) -> int:
escoria.current_state = escoria.GAME_STATE.DIALOG
if !escoria.dialog_player:
escoria.logger.error(
self,
"[%s]: No dialog player was registered and the say command was encountered."
% get_command_name()
)
escoria.current_state = escoria.GAME_STATE.DEFAULT
return ESCExecution.RC_ERROR
if not escoria.main.current_scene.player:
escoria.logger.warn(
self,
"[%s]: No player item in the current scene was registered and the say command was encountered."
% get_command_name()
)
escoria.current_state = escoria.GAME_STATE.DEFAULT
return ESCExecution.RC_CANCEL
var text = command_params[1] + "_" + String(rng.randi_range(command_params[2],command_params[3])) + ':" "'
var speaking_character_global_id = escoria.main.current_scene.player.global_id \
if command_params[0].to_upper() == CURRENT_PLAYER_KEYWORD \
else command_params[0]
escoria.dialog_player.say(
speaking_character_global_id,
"",
text
)
yield(escoria.dialog_player, "say_finished")
escoria.current_state = escoria.GAME_STATE.DEFAULT
return ESCExecution.RC_OK
# Function called when the command is interrupted.
func interrupt():
escoria.logger.debug(
self,
"[%s] interrupt() function not implemented." % get_command_name()
)

View File

@@ -46,7 +46,7 @@ onready var is_paused: bool = true
# Enable bbcode and catch the signal when a tween completed
func _ready():
_text_time_per_character = ProjectSettings.get_setting(
SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS
RTMISimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS
)
if _text_time_per_character < 0:
@@ -54,15 +54,15 @@ func _ready():
self,
"%s setting must be a non-negative number. Will use default value of %s." %
[
SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS,
SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE
RTMISimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS,
RTMISimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE
]
)
_text_time_per_character = SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE
_text_time_per_character = RTMISimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE
_fast_text_time_per_character = ProjectSettings.get_setting(
SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_FAST
RTMISimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_FAST
)
if _fast_text_time_per_character < 0:
@@ -70,15 +70,15 @@ func _ready():
self,
"%s setting must be a non-negative number. Will use default value of %s." %
[
SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_FAST,
SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE
RTMISimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_FAST,
RTMISimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE
]
)
_fast_text_time_per_character = SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE
_fast_text_time_per_character = RTMISimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE
_reading_speed_in_wpm = ProjectSettings.get_setting(
SimpleDialogPlugin.READING_SPEED_IN_WPM
RTMISimpleDialogPlugin.READING_SPEED_IN_WPM
)
if _reading_speed_in_wpm <= 0:
@@ -86,12 +86,12 @@ func _ready():
self,
"%s setting must be a positive number. Will use default value of %s." %
[
SimpleDialogPlugin.READING_SPEED_IN_WPM,
SimpleDialogPlugin.READING_SPEED_IN_WPM_DEFAULT_VALUE
RTMISimpleDialogPlugin.READING_SPEED_IN_WPM,
RTMISimpleDialogPlugin.READING_SPEED_IN_WPM_DEFAULT_VALUE
]
)
_reading_speed_in_wpm = SimpleDialogPlugin.READING_SPEED_IN_WPM_DEFAULT_VALUE
_reading_speed_in_wpm = RTMISimpleDialogPlugin.READING_SPEED_IN_WPM_DEFAULT_VALUE
_word_regex.compile("\\S+")
@@ -227,7 +227,7 @@ func _get_number_of_words() -> int:
# Ending the dialog
func _on_dialog_finished():
# Only trigger to clear the text if we aren't limiting the clearing trigger to a click.
if not ESCProjectSettingsManager.get_setting(SimpleDialogPlugin.CLEAR_TEXT_BY_CLICK_ONLY):
if not ESCProjectSettingsManager.get_setting(RTMISimpleDialogPlugin.CLEAR_TEXT_BY_CLICK_ONLY):
emit_signal("say_finished")

View File

@@ -18,3 +18,4 @@ func set_outline_color(color):
func set_outline_width(new_width):
Width = new_width
update()