mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 14:01:37 +00:00
Add localization test project, fix empty rows in general
This commit is contained in:
parent
147545e2f8
commit
1b749176fc
6 changed files with 114 additions and 9 deletions
|
|
@ -520,12 +520,32 @@ struct LocalizationEntryCsv {
|
|||
|
||||
impl LocalizationEntryCsv {
|
||||
fn to_json(self) -> LocalizationEntryJson {
|
||||
fn none_if_empty(value: String) -> Option<String> {
|
||||
if value.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(value)
|
||||
}
|
||||
}
|
||||
|
||||
let key = none_if_empty(self.key);
|
||||
let context = none_if_empty(self.context);
|
||||
let example = none_if_empty(self.example);
|
||||
let source = none_if_empty(self.source);
|
||||
|
||||
let mut values = HashMap::with_capacity(self.values.len());
|
||||
for (key, value) in self.values.into_iter() {
|
||||
if !key.is_empty() {
|
||||
values.insert(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
LocalizationEntryJson {
|
||||
key: self.key,
|
||||
context: self.context,
|
||||
example: self.example,
|
||||
source: self.source,
|
||||
values: self.values,
|
||||
key,
|
||||
context,
|
||||
example,
|
||||
source,
|
||||
values,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -533,10 +553,18 @@ impl LocalizationEntryCsv {
|
|||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct LocalizationEntryJson {
|
||||
key: String,
|
||||
context: String,
|
||||
example: String,
|
||||
source: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
key: Option<String>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
context: Option<String>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
example: Option<String>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
source: Option<String>,
|
||||
|
||||
values: HashMap<String, String>,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ macro_rules! generate_snapshot_tests {
|
|||
|
||||
generate_snapshot_tests!(
|
||||
empty,
|
||||
localization,
|
||||
multi_partition_game,
|
||||
nested_partitions,
|
||||
single_partition_game,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue