Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n fixes + sync #60

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

i18n fixes + sync #60

wants to merge 9 commits into from

Conversation

Klemen2
Copy link

@Klemen2 Klemen2 commented Oct 11, 2024

The current i18n implementation is quite limited, since I'm making a multi-window project I upgraded it with sync version of a signal

  • fixed an issue where if id is not found in the language that exists, it returns empty string instead of fallback
  • fixed an issue where if id is not found in the fallback language that exists, it returns empty string instead of id
  • added docs
  • added sync version for usage with mutex / rwlock for multiwindow applications
  • added better fallback support (similar to https://www.i18next.com/principles/fallback)
  • added a way to iterate through the languages for easier language selection
  • added extra optional field for language name - usually you want to be in a language that the translation is in, not in the displayed language otherwise someone would not be able to read what language they are selecting since they cannot read or understand the language that is currently selected
  • added extra optional field for language image - just so it's easier to make add it with iterator

Works in 0.5 for web and windows, cannot test mac or linux

Klemen2 and others added 9 commits June 10, 2024 17:51
Changed languages vector to hashmap
translate does not use empty hashmap
Language.get_text is now Language. get_text_with_params
Language.get_text just returns text without formating

Example now shows fallback in action
changed selected to is_selected it now returns a &str,
name is now optional
added new optional field img
- Added sync for use in mutex / rwlock
- content reorder
@marc2332
Copy link
Collaborator

marc2332 commented Oct 11, 2024

I suggest you take a look at https://crates.io/crates/dioxus-i18n first and see if that fits you better, we will probably remove i18n support from the sdk as the new crate has more features, let me know what you think

@marc2332 marc2332 self-requested a review October 11, 2024 22:05
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