UNPKG

@j2inn/app

Version:

J2 Innovations core application framework

49 lines (48 loc) 1.42 kB
/* * Copyright (c) 2022, J2 Innovations. All Rights Reserved */ /** * Returns the app's name to use for i18n. * * @param app The app or app id. * @returns The i18n key to use for getting the app view's name. */ export function getAppName(app) { return `${typeof app === 'string' ? app : app.id}.name`; } /** * Returns the app view's id. * * @param app The app or app id. * @parama appViewKey The key to the application view. * @returns The id for the app view. */ export function getAppViewId(app, appViewKey) { return `${typeof app === 'string' ? app : app.id}.${appViewKey}`; } /** * Returns the app view's name to use for i18n. * * @param app The app or app id. * @param appView The app view for the app. * @returns The i18n key to use for getting the app view's name. */ export function getAppViewName(app, appViewKey) { return `${getAppViewId(app, appViewKey)}.name`; } /** * Return the translated app name. * * This method attempts to translate the app's name but if an entry * can't be found then it falls back to trying to load the translated * string from the `finUi` app. * * @param appName The app (or app view) name. * @param i18n The internationalization object. * @returns The translated string. */ export function getTranslatedAppName(appViewName, i18n) { return i18n.has(appViewName) ? i18n.get(appViewName) : i18n.get(`finUi.${appViewName}`); }