(cherry picked from commit 139412284276479921632ee5ef1dabe76c5388b4) Rename LocalizationLanguageResource to avoid collision with LanguageResource (cherry picked from commit d2cd3f77169887086980feac3bab1f16301d189e)pull/9060/head
parent
933d9e074c
commit
e50abd276e
@ -0,0 +1,27 @@
|
|||||||
|
import createAjaxRequest from 'Utilities/createAjaxRequest';
|
||||||
|
|
||||||
|
function getTranslations() {
|
||||||
|
return createAjaxRequest({
|
||||||
|
global: false,
|
||||||
|
dataType: 'json',
|
||||||
|
url: '/localization/language'
|
||||||
|
}).request;
|
||||||
|
}
|
||||||
|
|
||||||
|
let languageNames = new Intl.DisplayNames(['en'], { type: 'language' });
|
||||||
|
|
||||||
|
getTranslations().then((data) => {
|
||||||
|
const names = new Intl.DisplayNames([data.identifier], { type: 'language' });
|
||||||
|
|
||||||
|
if (names) {
|
||||||
|
languageNames = names;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default function getLanguageName(code) {
|
||||||
|
if (!languageNames) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
return languageNames.of(code) ?? code;
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
namespace Radarr.Api.V3.Localization
|
||||||
|
{
|
||||||
|
public class LocalizationLanguageResource
|
||||||
|
{
|
||||||
|
public string Identifier { get; set; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue