@adminforth/i18n 1.1.3-next.5 → 1.2.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build.log CHANGED
@@ -16,5 +16,5 @@ custom/package-lock.json
16
16
  custom/package.json
17
17
  custom/tsconfig.json
18
18
 
19
- sent 24,824 bytes received 229 bytes 50,106.00 bytes/sec
19
+ sent 24,836 bytes received 229 bytes 50,130.00 bytes/sec
20
20
  total size is 23,969 speedup is 0.96
package/dist/index.js CHANGED
@@ -128,6 +128,7 @@ export default class I18nPlugin extends AdminForthPlugin {
128
128
  throw new Error(`Invalid language code ${lang}, please define valid ISO 639-1 language code (2 lowercase letters)`);
129
129
  }
130
130
  });
131
+ this.externalAppOnly = this.options.externalAppOnly === true;
131
132
  // find primary key field
132
133
  this.primaryKeyFieldName = (_a = resourceConfig.columns.find(c => c.primaryKey)) === null || _a === void 0 ? void 0 : _a.name;
133
134
  if (!this.primaryKeyFieldName) {
@@ -236,18 +237,20 @@ export default class I18nPlugin extends AdminForthPlugin {
236
237
  }))
237
238
  };
238
239
  // add underLogin component
239
- (adminforth.config.customization.loginPageInjections.underInputs).push({
240
- file: this.componentPath('LanguageUnderLogin.vue'),
241
- meta: compMeta
242
- });
243
- (adminforth.config.customization.globalInjections.userMenu).push({
244
- file: this.componentPath('LanguageInUserMenu.vue'),
245
- meta: compMeta
246
- });
247
- adminforth.config.customization.globalInjections.everyPageBottom.push({
248
- file: this.componentPath('LanguageEveryPageLoader.vue'),
249
- meta: compMeta
250
- });
240
+ if (!this.externalAppOnly) {
241
+ (adminforth.config.customization.loginPageInjections.underInputs).push({
242
+ file: this.componentPath('LanguageUnderLogin.vue'),
243
+ meta: compMeta
244
+ });
245
+ (adminforth.config.customization.globalInjections.userMenu).push({
246
+ file: this.componentPath('LanguageInUserMenu.vue'),
247
+ meta: compMeta
248
+ });
249
+ adminforth.config.customization.globalInjections.everyPageBottom.push({
250
+ file: this.componentPath('LanguageEveryPageLoader.vue'),
251
+ meta: compMeta
252
+ });
253
+ }
251
254
  // disable create allowedActions for translations
252
255
  resourceConfig.options.allowedActions.create = false;
253
256
  // add hook to validate user did not screw up with template params
@@ -618,7 +621,9 @@ ${JSON.stringify(strings.reduce((acc, s) => {
618
621
  throw new Error(`Field ${this.options.categoryFieldName} should be of type string in resource ${resourceConfig.resourceId}, but it is ${categoryColumn.type}`);
619
622
  }
620
623
  // in this plugin we will use plugin to fill the database with missing language messages
621
- this.tryProcessAndWatch(adminforth);
624
+ if (!this.externalAppOnly) {
625
+ this.tryProcessAndWatch(adminforth);
626
+ }
622
627
  adminforth.tr = (msg, category, lang, params, pluralizationNumber) => __awaiter(this, void 0, void 0, function* () {
623
628
  if (!msg) {
624
629
  return msg;
package/index.ts CHANGED
@@ -94,6 +94,8 @@ export default class I18nPlugin extends AdminForthPlugin {
94
94
 
95
95
  adminforth: IAdminForth;
96
96
 
97
+ externalAppOnly: boolean;
98
+
97
99
  // sorted by name list of all supported languages, without en e.g. 'al|ro|uk'
98
100
  fullCompleatedFieldValue: string;
99
101
 
@@ -140,7 +142,8 @@ export default class I18nPlugin extends AdminForthPlugin {
140
142
  throw new Error(`Invalid language code ${lang}, please define valid ISO 639-1 language code (2 lowercase letters)`);
141
143
  }
142
144
  });
143
-
145
+
146
+ this.externalAppOnly = this.options.externalAppOnly === true;
144
147
 
145
148
  // find primary key field
146
149
  this.primaryKeyFieldName = resourceConfig.columns.find(c => c.primaryKey)?.name;
@@ -265,20 +268,22 @@ export default class I18nPlugin extends AdminForthPlugin {
265
268
  ))
266
269
  };
267
270
  // add underLogin component
268
- (adminforth.config.customization.loginPageInjections.underInputs).push({
269
- file: this.componentPath('LanguageUnderLogin.vue'),
270
- meta: compMeta
271
- });
271
+ if (!this.externalAppOnly) {
272
+ (adminforth.config.customization.loginPageInjections.underInputs).push({
273
+ file: this.componentPath('LanguageUnderLogin.vue'),
274
+ meta: compMeta
275
+ });
272
276
 
273
- (adminforth.config.customization.globalInjections.userMenu).push({
274
- file: this.componentPath('LanguageInUserMenu.vue'),
275
- meta: compMeta
276
- });
277
+ (adminforth.config.customization.globalInjections.userMenu).push({
278
+ file: this.componentPath('LanguageInUserMenu.vue'),
279
+ meta: compMeta
280
+ });
277
281
 
278
- adminforth.config.customization.globalInjections.everyPageBottom.push({
279
- file: this.componentPath('LanguageEveryPageLoader.vue'),
280
- meta: compMeta
281
- });
282
+ adminforth.config.customization.globalInjections.everyPageBottom.push({
283
+ file: this.componentPath('LanguageEveryPageLoader.vue'),
284
+ meta: compMeta
285
+ });
286
+ }
282
287
 
283
288
  // disable create allowedActions for translations
284
289
  resourceConfig.options.allowedActions.create = false;
@@ -735,7 +740,9 @@ JSON.stringify(strings.reduce((acc: object, s: { en_string: string }): object =>
735
740
  }
736
741
 
737
742
  // in this plugin we will use plugin to fill the database with missing language messages
738
- this.tryProcessAndWatch(adminforth);
743
+ if (!this.externalAppOnly) {
744
+ this.tryProcessAndWatch(adminforth);
745
+ }
739
746
 
740
747
  adminforth.tr = async (msg: string | null | undefined, category: string, lang: string, params, pluralizationNumber: number): Promise<string> => {
741
748
  if (!msg) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/i18n",
3
- "version": "1.1.3-next.5",
3
+ "version": "1.2.0-next.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
package/types.ts CHANGED
@@ -36,4 +36,10 @@ export interface PluginOptions {
36
36
  * semiautomatically (creates a bulk action for generating translations)
37
37
  */
38
38
  completeAdapter?: CompletionAdapter
39
+
40
+ /**
41
+ * Optionally translation plugin available to translate only external applications (like SEO-facing or user-facing services),
42
+ * not AdminForth applications
43
+ */
44
+ externalAppOnly?: boolean;
39
45
  }