Allow more languages to be maintained by the project
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 14.6k
- Forks
- 734
- Avg merge
- 8h 40m
- Merged PRs (30d)
- 4
Description
Right now, localizations are stored like this:
https://github.com/microsoft/edit/blob/c13b8ab2f6f76288dd4682e24fba239c19e383b7/src/bin/edit/localization.rs#L244-L257
In other words, it's a matrix where the _outer_ index is the string ID and the _inner_ index is the language ID. Due to this it's impossible toggle languages on and off. What we need is ideally something like this:
```rs
const S_LANG_LUT: [[&str; _]; _] = generate_lut();
const generate_lut() -> [[&str; _]; _] {
let mut lut = [[""; _]; _];
#[cfg(feature = "lang-en")]
lut[NewFile][en] = "New File…";
#[cfg(feature = "lang-de")]
lut[NewFile][de] = "Neue Datei…";
#[cfg(feature = "lang-es")]
lut[NewFile][es] = "Nuevo archivo…";
#[cfg(feature = "lang-fr")]
lut[NewFile][fr] = "Nouveau fichier…";
#[cfg(feature = "lang-it")]
lut[NewFile][it] = "Nuovo file…";
#[cfg(feature = "lang-ja")]
lut[NewFile][ja] = "新規ファイル…";
#[cfg(feature = "lang-ko")]
lut[NewFile][ko] = "새 파일…";
#[cfg(feature = "lang-pt_br")]
lut[NewFile][pt_br] = "Novo arquivo…";
#[cfg(feature = "lang-ru")]
lut[NewFile][ru] = "Новый файл…";
#[cfg(feature = "lang-zh_hans")]
lut[NewFile][zh_hans] = "新建文件…";
#[cfg(feature = "lang-zh_hant")]
lut[NewFile][zh_hant] = "新增檔案…";
lut
}
```
Perhaps this can be abstracted away with a macro?
This then allows us to add more languages and toggle them on and off depending on the needs. Someone who wants the smallest possible editor for instance may disable everything except for `lang-en`. This is absolutely not a problem yet: The current localizations are only about 10kB large. Rather, I think that this may otherwise grow into an issue long-term, given that there's _a lot_ of languages out there.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/bin/edit/localization.rs#L244-L257 and trace how the string-by-language matrix and language IDs are consumed. Compare the proposed const LUT or macro approach with the existing localization structure. Done means individual lang-* features can be enabled or disabled while the supported localizations continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, localization
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100