diff --git a/src/components/scrollable/index.tsx b/src/components/scrollable/index.tsx index 26611ee4b..6aa49f682 100644 --- a/src/components/scrollable/index.tsx +++ b/src/components/scrollable/index.tsx @@ -63,10 +63,10 @@ export function Scrollable(props: IScrollbarProps) { ref={scroller} {...(custom as any)} wrapperProps={{ - renderer: ({ elementRef, style, ...restProps }) => { + renderer: ({ elementRef, style, key, ...restProps }) => { const currentTop = scroller.current?.scrollTop || 0; return ( - <> +
0 && 'active' )} /> - + ); }, }} diff --git a/src/i18n/localize.tsx b/src/i18n/localize.tsx index 03fb641af..22e746d98 100644 --- a/src/i18n/localize.tsx +++ b/src/i18n/localize.tsx @@ -9,10 +9,37 @@ export interface ILocalizeProps { defaultValue?: string; } -export function localize(sourceKey: string, defaultValue: string): any { - const localizedValue = container +const LOCALIZE_REPLACED_WORD = '${i}'; + +/** + * Returns the international text located by source key,or the default value if it is not find + * For examples: + * ```ts + * localize('id','default value'); // hello ${i}, ${i} + * localize('id','default value', 'world'); // hello world, ${i} + * localize('id','default value', 'world', 'molecule'); // hello world, molecule + * ``` + * @param sourceKey The key value located in the source internaional text + * @param defaultValue The default value to be used when not find the international text + * @param args If provided, it will used as the values to be replaced in the international text + * @returns + */ +export function localize( + sourceKey: string, + defaultValue: string, + ...args: string[] +): any { + let localizedValue = container .resolve(LocaleService) .localize(sourceKey, defaultValue); + if (args.length) { + args.forEach((replacedVal) => { + localizedValue = localizedValue.replace( + LOCALIZE_REPLACED_WORD, + replacedVal + ); + }); + } return localizedValue; }