- translateBy (npmName: string, toTranslate: string) {
- const helpers = this.helpers[npmName]
- if (!helpers) {
- console.error('Unknown helpers to translate %s from %s.', toTranslate, npmName)
- return toTranslate
+ getRegisteredClientRoute (route: string) {
+ return this.clientRoutes[route]
+ }
+
+ getAllRegisteredClientRoutes () {
+ return Object.keys(this.clientRoutes)
+ }
+
+ async translateSetting (npmName: string, setting: RegisterClientFormFieldOptions) {
+ for (const key of [ 'label', 'html', 'descriptionHTML' ]) {
+ if (setting[key]) setting[key] = await this.translateBy(npmName, setting[key])
+ }
+
+ if (Array.isArray(setting.options)) {
+ const newOptions = []
+
+ for (const o of setting.options) {
+ newOptions.push({
+ value: o.value,
+ label: await this.translateBy(npmName, o.label)
+ })
+ }
+
+ setting.options = newOptions