parent
84e6649724
commit
1394122842
@ -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 Sonarr.Api.V3.Localization
|
||||
{
|
||||
public class LanguageResource
|
||||
{
|
||||
public string Identifier { get; set; }
|
||||
}
|
||||
}
|
Loading…
Reference in new issue