mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2024-11-22 23:50:52 +01:00
Fix regex for localize text
This commit is contained in:
parent
49a06a3d4b
commit
1df2599e6c
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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>;
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user