Skip to content

Resolve #40 language switching#51

Merged
RailKill merged 17 commits into
devfrom
feature/languages
Jan 19, 2025
Merged

Resolve #40 language switching#51
RailKill merged 17 commits into
devfrom
feature/languages

Conversation

@RailKill

@RailKill RailKill commented Jan 19, 2025

Copy link
Copy Markdown
Collaborator

Language switcher should work for the following:

  • SentenceNode
    • Sentence
    • Voiceline
  • ChoiceNode
    • Option

The class Localizable which extends Property is added. Basically, values in Localizable are always stored as Dictionary, where it will automatically get the currently selected language from the global language switcher. For example, if you have English and Spanish in the language switcher, and have Spanish selected, setting hola as a value in Localizable will be stored internally as:

{"Spanish": "hola"}

This dictionary is outputted only on _to_dict(), but if you're just calling localizable.value, it has a getter to automatically retrieve the correct value based on the currently selected language. When selecting a language, it will trigger a GlobalSignal to refresh all node previews and side panel so that it will use the corresponding language's values.

The .json and graph_edits now store an additional languages variable. Each graph_edit keeps track of the current_language_index to support tab-switching. Undo/redo should automatically switch languages when needed.

Example JSON Structure: SentenceNode

Before

"Sentence": "Hello this is a test",
"Voiceline": "eng.mp3"

After

"Sentence": {
    "English": "Hello this is a test",
    "Spanish": "hola esto es una prueba"
},
"Voiceline": {
    "English": "eng.mp3"
}

Top-level addition:

"Languages": [
    "English",
    "Spanish"
]

Notes

For now, the following features are missing but could be useful in future:

  • No hotkey to switch language quickly.
  • No quick way to compare multiple languages side-by-side.

@RailKill RailKill requested a review from atomic-junky January 19, 2025 05:36
@RailKill RailKill changed the title Implement #40 Resolve #40 language switching Jan 19, 2025
@atomic-junky

Copy link
Copy Markdown
Collaborator

I love this feature, thank you so much for implementing it!
The only little problem I see is when you rename a language, you have to reselect it for the name to appear in the toolbox. And the selected language should have a different stylebox.

I also got an error on line 56 of monologue_dropdown.gd saying that item_id is a String and it cannot be converted to an int. It's always appening when I select a node.

@atomic-junky

atomic-junky commented Jan 19, 2025

Copy link
Copy Markdown
Collaborator

In fact, I think it's because of the redesign of the characters. I tested with a new file and everything works. My bad.

@atomic-junky atomic-junky left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me👍🏼

@RailKill RailKill merged commit 4aa1e04 into dev Jan 19, 2025
@RailKill RailKill deleted the feature/languages branch January 19, 2025 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants