react-native-localize-ext
Version:
make i18n in react-native much smoother
26 lines (21 loc) • 652 B
text/typescript
import { I18n } from './I18n';
export class I18nPolyfill<U extends object = object, T = object> extends I18n<U, T> {
protected createProxy(data: object, allProperties: string[], useDefaultLocal: boolean) {
const proxyData = {};
let toDefineProperty = { ...data };
if (!useDefaultLocal) {
toDefineProperty = {
...toDefineProperty,
...this.recursiveDefaultData(allProperties),
};
}
Object.keys(toDefineProperty).forEach((property) => {
Object.defineProperty(proxyData, property, {
get: () => {
return this.getProxyData(data, allProperties, property, useDefaultLocal);
},
});
});
return proxyData;
}
}