localize
This is an alternative to getLocalizedString that can be used with tagged templates. Using this function, you can localize template strings without running getLocalizedString on all the static strings. It will automatically replace the dynamic values with $n, where n is the index of the value, and then use getLocalizedString to translate the string.
In this example, the string that is translated by Appframe is "You are on page $0 of $1". If the user session has UI culture "nb-NO", the translated string will then be "Du er på side $0 av $1", where localize will replace $0 with the value of page, and $1 with the value of pageCount.
import { localize } from "@olenbetong/appframe-core";
import { usePaging } from "@olenbetong/appframe-react";
function CurrentPageText() {
let { page, pageCount } = usePaging(dsMyDataObject);
return localize`You are on page ${page} of ${pageCount}.`;
}Last updated
Was this helpful?