diff --git a/src/main/web/api/services/template/functions/LanguageFunctions.ts b/src/main/web/api/services/template/functions/LanguageFunctions.ts new file mode 100644 index 000000000..76c3e10b0 --- /dev/null +++ b/src/main/web/api/services/template/functions/LanguageFunctions.ts @@ -0,0 +1,26 @@ +/** + * ResearchSpace + * Copyright (C) 2020, © Trustees of the British Museum + * Copyright (C) 2015-2019, metaphacts GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import { getPreferredUserLanguage } from 'platform/api/services/language'; + +export const LanguageFunctions = { + userPreferredLanguage: function() { + return getPreferredUserLanguage(); + } +}; diff --git a/src/main/web/api/services/template/functions/index.ts b/src/main/web/api/services/template/functions/index.ts index 5f389065d..1cfdc83ff 100644 --- a/src/main/web/api/services/template/functions/index.ts +++ b/src/main/web/api/services/template/functions/index.ts @@ -24,6 +24,7 @@ import { RdfFunctions } from './RdfFunctions'; import { UriComponentFunctions } from './UriComponentFunctions'; import { NumbersFunctions } from './NumbersFunctions'; import { StringsFunctions } from './StringsFunctions'; +import { LanguageFunctions } from './LanguageFunctions'; export const DefaultHelpers = { ...DataContextFunctions, @@ -32,7 +33,8 @@ export const DefaultHelpers = { ...RdfFunctions, ...UriComponentFunctions, ...NumbersFunctions, - ...StringsFunctions + ...StringsFunctions, + ...LanguageFunctions }; export { ContextCapturer, CapturedContext } from './DataContextFunctions';