Skip to content

Commit 44f3d61

Browse files
committed
Default Android 'values/' folder to English in language inference
Updates language inference logic to treat the base 'values/' directory in Android projects as English ('en') by default. Adjusts related documentation and test assertions to reflect this behavior.
1 parent a5d4bbc commit 44f3d61

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

langcodec/src/converter.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ pub fn infer_format_from_extension<P: AsRef<Path>>(path: P) -> Option<FormatType
295295
/// );
296296
/// assert_eq!(
297297
/// infer_format_from_path("values/strings.xml"),
298-
/// Some(FormatType::AndroidStrings(None))
298+
/// Some(FormatType::AndroidStrings(Some("en".to_string())))
299299
/// );
300300
/// assert_eq!(
301301
/// infer_format_from_path("Localizable.xcstrings"),
@@ -364,7 +364,7 @@ pub fn infer_format_from_path<P: AsRef<Path>>(path: P) -> Option<FormatType> {
364364
/// // No language in path
365365
/// assert_eq!(
366366
/// infer_language_from_path("values/strings.xml", &FormatType::AndroidStrings(None)).unwrap(),
367-
/// None
367+
/// Some("en".to_string())
368368
/// );
369369
/// ```
370370
pub fn infer_language_from_path<P: AsRef<Path>>(
@@ -453,7 +453,11 @@ pub fn infer_language_from_path<P: AsRef<Path>>(
453453
}
454454
}
455455
FormatType::AndroidStrings(_) => {
456-
// Android: values-xx, values-xx-rYY, values-b+zh+Hans+CN, etc.
456+
// Android: values (default → en), values-xx, values-xx-rYY, values-b+zh+Hans+CN, etc.
457+
if comp == "values" {
458+
// Treat base `values/` as English by default
459+
return Ok(Some("en".to_string()));
460+
}
457461
if let Some(lang) = parse_android_values_lang(&comp) {
458462
return Ok(Some(lang));
459463
}

0 commit comments

Comments
 (0)