Skip to content

Commit

Permalink
Add new characters, update fonts, and expand localization support wit…
Browse files Browse the repository at this point in the history
…h country codes
  • Loading branch information
nullchinchilla committed May 4, 2024
1 parent 6038a93 commit eb20f53
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 7 deletions.
98 changes: 98 additions & 0 deletions binaries/geph5-client-gui/src/assets/chars.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ _
a
A
ā
Ā
b
B
c
Expand All @@ -46,6 +47,7 @@ d
D
e
E
ē
f
F
g
Expand All @@ -56,6 +58,7 @@ H
i
I
ī
Ī
j
J
k
Expand Down Expand Up @@ -83,6 +86,7 @@ T
u
U
ū
v
V
w
Expand All @@ -96,19 +100,24 @@ Z
а
А
б
Б
в
В
г
Г
д
Д
е
Е
ж
Ж
з
З
и
И
й
к
К
л
м
М
Expand All @@ -123,75 +132,160 @@ Z
с
С
т
Т
у
У
ф
Ф
х
Х
ц
ч
Ч
ш
Ш
щ
ы
ь
э
ю
Ю
я
Я
西
Expand All @@ -206,6 +300,10 @@ Z
Binary file modified binaries/geph5-client-gui/src/assets/chinese.ttf
Binary file not shown.
Binary file modified binaries/geph5-client-gui/src/assets/normal.otf
Binary file not shown.
50 changes: 50 additions & 0 deletions binaries/geph5-client-gui/src/l10n.csv
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,56 @@ cancel,Cancel,取消,Отмена,Lagv
connect,Connect,连接,Подключить,Etesāl
connected,Connected,已连接,Подключено,Mottasel
connection_time,Connection time,连接时间,Время соединения,Zamān-e etesāl
country_af,Afghanistan,阿富汗,Афганистан,Āfqānestān
country_ar,Argentina,阿根廷,Аргентина,Ārjāntīn
country_at,Austria,奥地利,Австрия,Otrīsh
country_au,Australia,澳大利亚,Австралия,Ostrālīyā
country_be,Belgium,比利时,Бельгия,Beljīk
country_bg,Bulgaria,保加利亚,Болгария,Bolgārīyā
country_br,Brazil,巴西,Бразилия,Brazīl
country_ca,Canada,加拿大,Канада,Kānādā
country_ch,Switzerland,瑞士,Швейцария,Sveyss
country_cl,Chile,智利,Чили,Chīlī
country_cn,China,中国,Китай,Chīn
country_co,Colombia,哥伦比亚,Колумбия,Colombīyā
country_de,Germany,德国,Германия,Ālmān
country_dk,Denmark,丹麦,Дания,Dānmārk
country_eg,Egypt,埃及,Египет,Mesr
country_es,Spain,西班牙,Испания,Espānyā
country_fi,Finland,芬兰,Финляндия,Fenlānd
country_fr,France,法国,Франция,Farānse
country_gb,United Kingdom,英国,Великобритания,Engelīs
country_gr,Greece,希腊,Греция,Yūnān
country_hr,Croatia,克罗地亚,Хорватия,Korūtīyā
country_hu,Hungary,匈牙利,Венгрия,Majarstān
country_id,Indonesia,印尼,Индонезия,Īndonīzīyā
country_ie,Ireland,爱尔兰,Ирландия,Īrlānd
country_il,Israel,以色列,Израиль,Isrā'īl
country_in,India,印度,Индия,Hend
country_ir,Iran,伊朗,Иран,Īrān
country_it,Italy,意大利,Италия,Ītālīyā
country_jp,Japan,日本,Япония,Jāpān
country_mx,Mexico,墨西哥,Мексика,Meksīkā
country_ng,Nigeria,尼日利亚,Нигерия,Nījīrīyā
country_nl,Netherlands,荷兰,Нидерланды,Holand
country_no,Norway,挪威,Норвегия,Narvēj
country_nz,New Zealand,新西兰,Новая Зеландия,Zelānd-e Now
country_ph,Philippines,菲律宾,Филиппины,Felīpīn
country_pl,Poland,波兰,Польша,Lāhestān
country_pt,Portugal,葡萄牙,Португалия,Portoghāl
country_ro,Romania,罗马尼亚,Румыния,Romānīyā
country_ru,Russia,俄罗斯,Россия,Rūsīye
country_sa,Saudi Arabia,沙特阿拉伯,Саудовская Аравия,Arabestān-e Sa'ūdī
country_se,Sweden,瑞典,Швеция,Sved
country_sg,Singapore,新加坡,Сингапур,Sīngāpūr
country_sk,Slovakia,斯洛伐克,Словакия,Slovākīyā
country_th,Thailand,泰国,Таиланд,Tāīlānd
country_tr,Turkey,土耳其,Турция,Torkīye
country_tw,Taiwan,台湾,Тайвань,Tāyvān
country_ua,Ukraine,乌克兰,Украина,Okrāīn
country_us,United States,美国,Соединенные Штаты,Īālāt-e Mottaḥed-e Amrīkā
country_ve,Venezuela,委内瑞拉,Венесуэла,Venēzūelā
country_za,South Africa,南非,Южная Африка,Afrīqā-ye Jonūbī
dashboard,Dashboard,仪表盘,Приборная панель,Dāšbord
data_used,Data used,已用流量,Использ. данные,Dādehā-ye maṣraf-šode
disconnect,Disconnect,断开连接,Отключить,Qat'-e etesāl
Expand Down
14 changes: 12 additions & 2 deletions binaries/geph5-client-gui/src/l10n.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::collections::BTreeMap;

use isocountry::CountryCode;
use once_cell::sync::Lazy;
use smol_str::SmolStr;

Expand All @@ -17,6 +18,15 @@ static L10N_TABLE: Lazy<BTreeMap<SmolStr, BTreeMap<SmolStr, SmolStr>>> = Lazy::n
toret
});

pub fn l10n(label: &str) -> &str {
&L10N_TABLE[label][&LANG_CODE.get()]
pub fn l10n(label: &str) -> &'static str {
if let Some(inner) = L10N_TABLE.get(label) {
if let Some(inner) = inner.get(&LANG_CODE.get()) {
return inner;
}
}
"(unk)"
}

pub fn l10n_country(country: CountryCode) -> &'static str {
l10n(&format!("country_{}", country.alpha2().to_lowercase()))
}
18 changes: 13 additions & 5 deletions binaries/geph5-client-gui/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ use itertools::Itertools;
use once_cell::sync::Lazy;
use smol_str::{SmolStr, ToSmolStr};

use crate::{l10n, refresh_cell::RefreshCell, store_cell::StoreCell};
use crate::{
l10n::{l10n, l10n_country},
refresh_cell::RefreshCell,
store_cell::StoreCell,
};

pub fn get_config() -> anyhow::Result<Config> {
let yaml: serde_yaml::Value = serde_yaml::from_str(include_str!("settings_default.yaml"))?;
Expand Down Expand Up @@ -126,7 +130,11 @@ pub fn render_settings(_ctx: &egui::Context, ui: &mut egui::Ui) -> anyhow::Resul
loop {
let fallible = async {
let exits = client.get_exits().await?.map_err(|e| anyhow::anyhow!(e))?;
anyhow::Ok(exits.inner)
let mut inner = exits.inner;
inner
.all_exits
.sort_unstable_by_key(|s| (s.1.country, s.1.city.clone()));
anyhow::Ok(inner)
};
match fallible.await {
Ok(v) => return v,
Expand All @@ -140,8 +148,8 @@ pub fn render_settings(_ctx: &egui::Context, ui: &mut egui::Ui) -> anyhow::Resul
.selected_text(
SELECTED_COUNTRY
.get()
.map(|s| s.to_string())
.unwrap_or_else(|| l10n("auto").to_string()),
.map(l10n_country)
.unwrap_or_else(|| l10n("auto")),
)
.show_ui(ui, |ui| {
let former = SELECTED_COUNTRY.get();
Expand All @@ -150,7 +158,7 @@ pub fn render_settings(_ctx: &egui::Context, ui: &mut egui::Ui) -> anyhow::Resul
ui.selectable_value(selected, None, l10n("auto"));

for country in locations.all_exits.iter().map(|s| s.1.country).unique() {
ui.selectable_value(selected, Some(country), country.to_string());
ui.selectable_value(selected, Some(country), l10n_country(country));
}
} else {
ui.spinner();
Expand Down

0 comments on commit eb20f53

Please sign in to comment.