Merge branch 'keyboard-layout-hebrew' into 'master'
Add Hebrew translations for most layouts. See merge request Librem5/squeekboard!439
This commit is contained in:
19
data/langs/he-IL.txt
Normal file
19
data/langs/he-IL.txt
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
be בלגית
|
||||||
|
br פורטוגזית (ברזיל)
|
||||||
|
cz צ'כית
|
||||||
|
de גרמנית
|
||||||
|
dk דנית
|
||||||
|
es ספרדית
|
||||||
|
emoji אימוג'י
|
||||||
|
fi פינית
|
||||||
|
fr צרפתית
|
||||||
|
gr יוונית
|
||||||
|
il עברית
|
||||||
|
it איטלקית
|
||||||
|
no נורווגית
|
||||||
|
pl פולנית
|
||||||
|
ru רוסית
|
||||||
|
se שוודית
|
||||||
|
terminal טרמינל
|
||||||
|
ua אוקראינית
|
||||||
|
us אנגלית (ארה"ב)
|
||||||
@ -2,8 +2,8 @@
|
|||||||
* This could be done using GResource, but that would need additional work.
|
* This could be done using GResource, but that would need additional work.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use std::collections::HashMap;
|
|
||||||
use ::locale::Translation;
|
use ::locale::Translation;
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
|
|
||||||
@ -16,75 +16,73 @@ const KEYBOARDS: &[(*const str, *const str)] = &[
|
|||||||
// fallback layout.
|
// fallback layout.
|
||||||
("us", include_str!("../data/keyboards/us.yaml")),
|
("us", include_str!("../data/keyboards/us.yaml")),
|
||||||
("us_wide", include_str!("../data/keyboards/us_wide.yaml")),
|
("us_wide", include_str!("../data/keyboards/us_wide.yaml")),
|
||||||
|
|
||||||
// Language layouts: keep alphabetical.
|
// Language layouts: keep alphabetical.
|
||||||
("be", include_str!("../data/keyboards/be.yaml")),
|
("be", include_str!("../data/keyboards/be.yaml")),
|
||||||
("be_wide", include_str!("../data/keyboards/be_wide.yaml")),
|
("be_wide", include_str!("../data/keyboards/be_wide.yaml")),
|
||||||
|
|
||||||
("bg", include_str!("../data/keyboards/bg.yaml")),
|
("bg", include_str!("../data/keyboards/bg.yaml")),
|
||||||
|
|
||||||
("br", include_str!("../data/keyboards/br.yaml")),
|
("br", include_str!("../data/keyboards/br.yaml")),
|
||||||
|
|
||||||
("de", include_str!("../data/keyboards/de.yaml")),
|
("de", include_str!("../data/keyboards/de.yaml")),
|
||||||
("de_wide", include_str!("../data/keyboards/de_wide.yaml")),
|
("de_wide", include_str!("../data/keyboards/de_wide.yaml")),
|
||||||
|
|
||||||
("cz", include_str!("../data/keyboards/cz.yaml")),
|
("cz", include_str!("../data/keyboards/cz.yaml")),
|
||||||
("cz_wide", include_str!("../data/keyboards/cz_wide.yaml")),
|
("cz_wide", include_str!("../data/keyboards/cz_wide.yaml")),
|
||||||
|
(
|
||||||
("cz+qwerty", include_str!("../data/keyboards/cz+qwerty.yaml")),
|
"cz+qwerty",
|
||||||
("cz+qwerty_wide", include_str!("../data/keyboards/cz+qwerty_wide.yaml")),
|
include_str!("../data/keyboards/cz+qwerty.yaml"),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"cz+qwerty_wide",
|
||||||
|
include_str!("../data/keyboards/cz+qwerty_wide.yaml"),
|
||||||
|
),
|
||||||
("dk", include_str!("../data/keyboards/dk.yaml")),
|
("dk", include_str!("../data/keyboards/dk.yaml")),
|
||||||
|
|
||||||
("epo", include_str!("../data/keyboards/epo.yaml")),
|
("epo", include_str!("../data/keyboards/epo.yaml")),
|
||||||
|
|
||||||
("es", include_str!("../data/keyboards/es.yaml")),
|
("es", include_str!("../data/keyboards/es.yaml")),
|
||||||
("es+cat", include_str!("../data/keyboards/es+cat.yaml")),
|
("es+cat", include_str!("../data/keyboards/es+cat.yaml")),
|
||||||
|
|
||||||
("fi", include_str!("../data/keyboards/fi.yaml")),
|
("fi", include_str!("../data/keyboards/fi.yaml")),
|
||||||
|
|
||||||
("fr", include_str!("../data/keyboards/fr.yaml")),
|
("fr", include_str!("../data/keyboards/fr.yaml")),
|
||||||
("fr_wide", include_str!("../data/keyboards/fr_wide.yaml")),
|
("fr_wide", include_str!("../data/keyboards/fr_wide.yaml")),
|
||||||
|
|
||||||
("gr", include_str!("../data/keyboards/gr.yaml")),
|
("gr", include_str!("../data/keyboards/gr.yaml")),
|
||||||
|
|
||||||
("il", include_str!("../data/keyboards/il.yaml")),
|
("il", include_str!("../data/keyboards/il.yaml")),
|
||||||
|
|
||||||
("ir", include_str!("../data/keyboards/ir.yaml")),
|
("ir", include_str!("../data/keyboards/ir.yaml")),
|
||||||
("ir_wide", include_str!("../data/keyboards/ir_wide.yaml")),
|
("ir_wide", include_str!("../data/keyboards/ir_wide.yaml")),
|
||||||
|
|
||||||
("it", include_str!("../data/keyboards/it.yaml")),
|
("it", include_str!("../data/keyboards/it.yaml")),
|
||||||
("it+fur", include_str!("../data/keyboards/it+fur.yaml")),
|
("it+fur", include_str!("../data/keyboards/it+fur.yaml")),
|
||||||
|
|
||||||
("jp+kana", include_str!("../data/keyboards/jp+kana.yaml")),
|
("jp+kana", include_str!("../data/keyboards/jp+kana.yaml")),
|
||||||
("jp+kana_wide", include_str!("../data/keyboards/jp+kana_wide.yaml")),
|
(
|
||||||
|
"jp+kana_wide",
|
||||||
|
include_str!("../data/keyboards/jp+kana_wide.yaml"),
|
||||||
|
),
|
||||||
("no", include_str!("../data/keyboards/no.yaml")),
|
("no", include_str!("../data/keyboards/no.yaml")),
|
||||||
|
|
||||||
("pl", include_str!("../data/keyboards/pl.yaml")),
|
("pl", include_str!("../data/keyboards/pl.yaml")),
|
||||||
("pl_wide", include_str!("../data/keyboards/pl_wide.yaml")),
|
("pl_wide", include_str!("../data/keyboards/pl_wide.yaml")),
|
||||||
|
|
||||||
("ru", include_str!("../data/keyboards/ru.yaml")),
|
("ru", include_str!("../data/keyboards/ru.yaml")),
|
||||||
|
|
||||||
("se", include_str!("../data/keyboards/se.yaml")),
|
("se", include_str!("../data/keyboards/se.yaml")),
|
||||||
|
|
||||||
("th", include_str!("../data/keyboards/th.yaml")),
|
("th", include_str!("../data/keyboards/th.yaml")),
|
||||||
("th_wide", include_str!("../data/keyboards/th_wide.yaml")),
|
("th_wide", include_str!("../data/keyboards/th_wide.yaml")),
|
||||||
|
|
||||||
("ua", include_str!("../data/keyboards/ua.yaml")),
|
("ua", include_str!("../data/keyboards/ua.yaml")),
|
||||||
|
(
|
||||||
("us+colemak", include_str!("../data/keyboards/us+colemak.yaml")),
|
"us+colemak",
|
||||||
("us+colemak_wide", include_str!("../data/keyboards/us+colemak_wide.yaml")),
|
include_str!("../data/keyboards/us+colemak.yaml"),
|
||||||
|
),
|
||||||
("us+dvorak", include_str!("../data/keyboards/us+dvorak.yaml")),
|
(
|
||||||
("us+dvorak_wide", include_str!("../data/keyboards/us+dvorak_wide.yaml")),
|
"us+colemak_wide",
|
||||||
|
include_str!("../data/keyboards/us+colemak_wide.yaml"),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"us+dvorak",
|
||||||
|
include_str!("../data/keyboards/us+dvorak.yaml"),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"us+dvorak_wide",
|
||||||
|
include_str!("../data/keyboards/us+dvorak_wide.yaml"),
|
||||||
|
),
|
||||||
// Others
|
// Others
|
||||||
("number", include_str!("../data/keyboards/number.yaml")),
|
("number", include_str!("../data/keyboards/number.yaml")),
|
||||||
|
|
||||||
// layout+overlay
|
// layout+overlay
|
||||||
("terminal", include_str!("../data/keyboards/terminal.yaml")),
|
("terminal", include_str!("../data/keyboards/terminal.yaml")),
|
||||||
("terminal_wide", include_str!("../data/keyboards/terminal_wide.yaml")),
|
(
|
||||||
|
"terminal_wide",
|
||||||
|
include_str!("../data/keyboards/terminal_wide.yaml"),
|
||||||
|
),
|
||||||
// Overlays
|
// Overlays
|
||||||
("emoji", include_str!("../data/keyboards/emoji.yaml")),
|
("emoji", include_str!("../data/keyboards/emoji.yaml")),
|
||||||
];
|
];
|
||||||
@ -92,7 +90,8 @@ const KEYBOARDS: &[(*const str, *const str)] = &[
|
|||||||
pub fn get_keyboard(needle: &str) -> Option<&'static str> {
|
pub fn get_keyboard(needle: &str) -> Option<&'static str> {
|
||||||
// Need to dereference in unsafe code
|
// Need to dereference in unsafe code
|
||||||
// comparing *const str to &str will compare pointers
|
// comparing *const str to &str will compare pointers
|
||||||
KEYBOARDS.iter()
|
KEYBOARDS
|
||||||
|
.iter()
|
||||||
.find(|(name, _)| {
|
.find(|(name, _)| {
|
||||||
let name: *const str = *name;
|
let name: *const str = *name;
|
||||||
(unsafe { &*name }) == needle
|
(unsafe { &*name }) == needle
|
||||||
@ -103,17 +102,16 @@ pub fn get_keyboard(needle: &str) -> Option<&'static str> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const OVERLAY_NAMES: &[*const str] = &[
|
const OVERLAY_NAMES: &[*const str] = &["emoji", "terminal"];
|
||||||
"emoji",
|
|
||||||
"terminal",
|
|
||||||
];
|
|
||||||
|
|
||||||
pub fn get_overlays() -> Vec<&'static str> {
|
pub fn get_overlays() -> Vec<&'static str> {
|
||||||
OVERLAY_NAMES.iter()
|
OVERLAY_NAMES
|
||||||
|
.iter()
|
||||||
.map(|name| {
|
.map(|name| {
|
||||||
let name: *const str = *name;
|
let name: *const str = *name;
|
||||||
unsafe { &*name }
|
unsafe { &*name }
|
||||||
}).collect()
|
})
|
||||||
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Translations of the layout identifier strings
|
/// Translations of the layout identifier strings
|
||||||
@ -122,15 +120,15 @@ const LAYOUT_NAMES: &[(*const str, *const str)] = &[
|
|||||||
("en-US", include_str!("../data/langs/en-US.txt")),
|
("en-US", include_str!("../data/langs/en-US.txt")),
|
||||||
("es-ES", include_str!("../data/langs/es-ES.txt")),
|
("es-ES", include_str!("../data/langs/es-ES.txt")),
|
||||||
("fur-IT", include_str!("../data/langs/fur-IT.txt")),
|
("fur-IT", include_str!("../data/langs/fur-IT.txt")),
|
||||||
|
("he-IL", include_str!("../data/langs/he-IL.txt")),
|
||||||
("ja-JP", include_str!("../data/langs/ja-JP.txt")),
|
("ja-JP", include_str!("../data/langs/ja-JP.txt")),
|
||||||
("pl-PL", include_str!("../data/langs/pl-PL.txt")),
|
("pl-PL", include_str!("../data/langs/pl-PL.txt")),
|
||||||
("ru-RU", include_str!("../data/langs/ru-RU.txt")),
|
("ru-RU", include_str!("../data/langs/ru-RU.txt")),
|
||||||
];
|
];
|
||||||
|
|
||||||
pub fn get_layout_names(lang: &str)
|
pub fn get_layout_names(lang: &str) -> Option<HashMap<&'static str, Translation<'static>>> {
|
||||||
-> Option<HashMap<&'static str, Translation<'static>>>
|
let translations = LAYOUT_NAMES
|
||||||
{
|
.iter()
|
||||||
let translations = LAYOUT_NAMES.iter()
|
|
||||||
.find(|(name, _data)| {
|
.find(|(name, _data)| {
|
||||||
let name: *const str = *name;
|
let name: *const str = *name;
|
||||||
(unsafe { &*name }) == lang
|
(unsafe { &*name }) == lang
|
||||||
@ -155,10 +153,7 @@ fn parse_line(line: &str) -> Option<(&str, Translation)> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn make_mapping(data: &str) -> HashMap<&str, Translation> {
|
fn make_mapping(data: &str) -> HashMap<&str, Translation> {
|
||||||
HashMap::from_iter(
|
HashMap::from_iter(data.split("\n").filter_map(parse_line))
|
||||||
data.split("\n")
|
|
||||||
.filter_map(parse_line)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
Reference in New Issue
Block a user