import { ActionSdkHelper } from "../helper/ActionSdkHelper" ; export class Localizer { private static jsonObject : { [ key ] : string ; } = { } ; return public static async initialize ( ) { let response = await ActionSdkHelper . getLocalizedStrings ( ) ; this . jsonObject = response . success && response . strings ; return response . success ; } param stringId param args public static getString ( id , ... args ) { if ( this . jsonObject && this . jsonObject [ id ] ) { return this . getStringInternal ( this . jsonObject [ id ] , ... args ) ; } return this . getStringInternal ( id , ... args ) ; } private static getStringInternal ( main , ... args ) { let formatted = main ; for ( let i = 0 ; i < args . length ; i ++ ) { let regexp = new RegExp ( "\\{" + i + "\\}" , "gi" ) ; formatted = formatted . replace ( regexp , args [ i ] ) ; } return formatted ; } }