Skip to content

Commit

Permalink
Merge pull request #500 from nextcloud/bugfix/100
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusknorr authored Dec 7, 2023
2 parents da023ad + 1352a34 commit ec72510
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/WOPI/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ private function getLanguageCode(): string {
return array_shift($languageMatches);
}

return 'en-US';
// Try to provide the language code matching RFC1766 format, if no language can be determined office will fallback to the browser language and then to en-US
// https://learn.microsoft.com/en-us/microsoft-365/cloud-storage-partner-program/online/discovery#ui_llcc
return str_replace('_', '-', $languageCode);
}
}
7 changes: 6 additions & 1 deletion tests/lib/WOPI/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ class ParserTest extends \Test\TestCase {
public function dataLanguage() {
return [
['de', 'de_DE', 'de-DE'],
['foo', 'de_DE', 'en-US'],
['foo', 'de_DE', 'foo'],
['en', 'en_US', 'en-US'],
['en', 'en_GB', 'en-gb'],
['en', 'de_DE', 'en-gb'],
['fr', 'fr_FR', 'fr-FR'],
['fr', 'fr_CA', 'fr-ca'],
['zh_CN', 'zh_CN', 'zh-CN'],
['zh_TW', 'zh_TW', 'zh-TW'],
['zh_CN', 'zh_Hans_CN', 'zh-CN'],
['zh_CN', 'zh_Hans_CN', 'zh-CN'],
['es_UY', 'es_UY', 'es-UY'],
];
}

Expand Down

0 comments on commit ec72510

Please sign in to comment.