Fix regex for localize text

This commit is contained in:
Bill 2022-03-15 18:45:10 -04:00
parent 49a06a3d4b
commit 1df2599e6c
3 changed files with 20 additions and 2 deletions

View File

@ -169,4 +169,9 @@ export class ConfigurationManager extends NitroManager implements IConfiguration
//@ts-ignore
return NitroConfig as { [index: string]: any };
}
public get definitions(): Map<string, unknown>
{
return this._definitions;
}
}

View File

@ -5,4 +5,5 @@ export interface IConfigurationManager extends INitroManager
interpolate(value: string, regex?: RegExp): string;
getValue<T>(key: string, value?: T): T;
setValue(key: string, value: string): void;
}
definitions: Map<string, unknown>;
}

View File

@ -119,10 +119,22 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca
{
if(!key || !key.length) return null;
if(key.startsWith('${')) key = key.substr(2, (key.length - 3));
const keys = key.match(/\$\{.[^}]*\}/g);
if(keys && keys.length)
{
for(const splitKey of keys) key = key.replace(splitKey, this.getValue(splitKey.slice(2, -1), doParams));
}
let value = (this._definitions.get(key) || null);
if(!value)
{
value = (Nitro.instance.core.configuration.definitions.get(key) as any);
if(value) return value;
}
if(value && doParams)
{
const parameters = this._parameters.get(key);