Localization/i18n RFC #43592
Replies: 6 comments 8 replies
-
|
Localization involves translating the app itself, as well as its plugins. In your design, how do plugin authors translate their works? If Zed releases language packs as plugins, is it possible to modify/notify all of them when a string is changed? |
Beta Was this translation helpful? Give feedback.
-
|
Hi, comments on your proposal:
Early vs late localizationOne difference between your proposal and what I'd suggest is the interaction between UI construction and l10n resolution. menu.entry(
t!(remove-from-project), // <-- HERE
None,
cx.handler_for(&this, move |this, cx| {
this.project.update(cx, |project, cx| {
project.remove_worktree(worktree_id, cx)
});
}),
)In this example the I believe this approach is deceptively bad for GUI applications, where the UI tree should be treated as a "source of truth" and allow for reactiveness - a'ka - partial or full retranslations based on the UI tree and env information. I documented this philosophy here raphlinus/crochet#7 and here unicode-org/message-format-wg#118 In that model, I'd recommend the above example to do: menu.entry(
"remove-from-project" // bind l10n id to the entry, l10n resolution is a step in layout construction later
None,
cx.handler_for(&this, move |this, cx| {
this.project.update(cx, |project, cx| {
project.remove_worktree(worktree_id, cx)
});
}),
)This binds the L10n Element to UI Element, rather than the resolved string to an UI element and allows for all sorts of reactiveness:
This is also in line with DOM L10n proposal - https://github.com/mozilla/explainers/blob/main/dom-localization.md The easiest analogy that I would use is that it's a difference like between passing resolved CSS values to an element constructor, vs CSS class binding. Managing themes is much easier with the latter. |
Beta Was this translation helpful? Give feedback.
-
|
When is the internationalization (i18n) feature expected to be launched? Many users are looking forward to localized UI support. Is there an official roadmap or an estimated release window? |
Beta Was this translation helpful? Give feedback.
-
|
Hi Team, As you know, we did similar struggling in NCSA Mosaic. When we made it and other components such as servers, we consisted on the I18N, not L10N. In this approach, you may seem the initial investment too much, however, the scalability and offloading were promised. However, the full wrapping of other system is vullnable from two aspects:
Indeed, 1. would need the intellectual property professionals, however, 2 makes us the urgent awareness of the possible severity and we may need the 3rd party inspector. We need to start the split the programming language and the human natural language. After these refactors, including the languages written from right to left, the ones using many different sizes of words in the same context, Anyway, as you split your words from your usual usage of languages to the prompts of LLMs, we need the solid and flexible based consensus and running codes. The programing code is the computer language and we can use the different format checkers, Can you write a converter from English to others in UTF8 by your own effort? After these step, finally, the minimum cost of human blush up. |
Beta Was this translation helpful? Give feedback.
-
|
Hi everyone, Regarding the implementation of i18n in Zed, I would like to suggest using
I believe this would make Zed much more accessible to a global audience while maintaining the project's commitment to efficiency and flexibility. What are your thoughts on this direction? |
Beta Was this translation helpful? Give feedback.
-
|
Zed v1.0 is released, so is there any progress about localization by official? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Localization/i18n proposal
Localizing a project of any size is deceptively complex. Localization touches an application in many places. Not only that, it demands building processes to maintain translations and building communities of users responsible for doing that maintenance. I’ve taken a stab at identifying all the major considerations. I have clear thoughts on some of these, but others are essentially placeholders for “remember to think about this.”
I wanted to pull this together and make it available for comment before starting any of the work, as I know there will be lots of interested stakeholders, many of whom come from regions outside the US and therefore bring valuable perspective to the problem.
I don’t think we need to answer literally every question in here before we can start on the work. There are a handful of critical decisions that have to be made; the rest can be planned out while that work is underway.
Overarching goals
Dependencies
fluent
I recommend that we integrate the Fluent library for localization
fluent-templates
Provides a useful abstraction for loading translations. (Also includes templating, but we won't need that.)
unic-locale
An API for managing locale identifiers.
Translation macro
I haven't found anything for fluent as nice for performing translation operations as the
t!macro from rust-i18n. We will probably want to steal and adapt that to work with fluent.Architecture
Loc resource storage
There are two schools of thought on this -- embedding strings directly in the binary, and loading them at startup. I think embedding is a non-starter; we want to permit volunteers to target new locales without having to think about the impact to startup time (or, for that matter, even to be required to build Zed themselves).
I recommend starting out with whatever string file format is supported by the localization crate we choose & loading the entire string table at startup. On top of this, add a metric that tracks the cost of string table load on startup so we can monitor for regressions. In the event this gets to the point where the startup cost is untenable, we can explore more complex but also more efficient approaches (memory-mapping string files, lazy loading, caching etc. etc.)
Initialization
Locale resolution
TBD, but consider something like https://docs.rs/locale-match/0.2.4/locale_match/, at least as a starting position.
String table loading
Here’s what I want to do. It might be overkill.
Rendering strategy
Make the caller do lookup
In this case, wherever you instantiate a component, you would have to call (probably!) a macro to translate your string in place, passing it an identifier.
Pros:
Cons:
Make components locale-aware
With this approach, we update the components to take the strings that are passed to them and “hash” them (this could be as simple as converting them to lower-kebab-case). These hashes get used as the string ids.
Pros:
Cons:
A mixture of both
We don’t make components locale-aware, so they can receive untranslated strings. However, we use the hashing-the-English-string-as-key approach from the locale-aware component proposal.
Pros:
Cons:
I favor this approach, mainly because it significantly reduces friction on UI developers, automating away the more laborious parts of the process, but doesn’t require updating every single component in the app. Having to go through and add a macro call to every string is laborious, but mostly grunt work and can probably be automated.
Token handling
We need to ensure tokens for things like numbers, dates, times are passed to the localization macro as rich types & not pre-rendered to strings and embedded. This will require some code searching.
We will need to then figure out which crates to use for rendering these elements in place and incorporate them into our rendering macro.
We will also need to establish conventions on how to pass tokens to the rendering system.
Settings
Error handling
Translation tooling
Requirements
Build and Release
t!macro and run some rudimentary tests, such as that the expected number of tokens are correctly supplied in code).Documentation
Future consideration
Component rework for specific locales
How do we populate the OS's UX elements?
Beta Was this translation helpful? Give feedback.
All reactions