@armoury/fivem-framework-client 1.0.48 → 1.0.53
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.
|
@@ -5,18 +5,23 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
8
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
13
|
};
|
|
14
|
+
var I18n_1;
|
|
11
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
16
|
exports.I18n = void 0;
|
|
13
17
|
const fivem_framework_common_1 = require("@armoury/fivem-framework-common");
|
|
14
18
|
const node_polyglot_1 = __importDefault(require("node-polyglot"));
|
|
15
19
|
const injection_js_1 = require("injection-js");
|
|
16
|
-
let I18n = class I18n {
|
|
20
|
+
let I18n = I18n_1 = class I18n {
|
|
17
21
|
static withOptions(options = {}) {
|
|
18
22
|
var _a;
|
|
19
|
-
const language = (_a =
|
|
23
|
+
const language = (_a = (Cfx.Client.GetResourceKvpString('armoury:language')
|
|
24
|
+
|| options.defaultLanguage)) !== null && _a !== void 0 ? _a : 'en-US';
|
|
20
25
|
return {
|
|
21
26
|
provide: fivem_framework_common_1.APP_INITIALIZER,
|
|
22
27
|
useValue: () => this.loadLanguage(language),
|
|
@@ -50,17 +55,26 @@ let I18n = class I18n {
|
|
|
50
55
|
console.warn(`Language not found: ${language}`);
|
|
51
56
|
}
|
|
52
57
|
}
|
|
53
|
-
console.log('translations are', translations);
|
|
54
58
|
this.polyglot.locale(language);
|
|
55
59
|
this.polyglot.replace(translations);
|
|
56
60
|
}
|
|
57
61
|
static translate(key, params = {}) {
|
|
58
|
-
console.log('translate() called! key:', key, 'params:', params);
|
|
59
62
|
return this.polyglot.t(key, params);
|
|
60
63
|
}
|
|
64
|
+
_onLanguageChangedRequestedUnsafe(language) {
|
|
65
|
+
console.log(`Setting language to ${language}.`);
|
|
66
|
+
Cfx.Client.SetResourceKvp('armoury:language', language);
|
|
67
|
+
I18n_1.setLanguage(language);
|
|
68
|
+
}
|
|
61
69
|
};
|
|
62
70
|
exports.I18n = I18n;
|
|
63
71
|
I18n.polyglot = new node_polyglot_1.default();
|
|
64
|
-
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, fivem_framework_common_1.EventListener)({ eventName: 'armoury:unsafe:language:change:request', direction: fivem_framework_common_1.EVENT_DIRECTIONS.CLIENT_TO_CLIENT }),
|
|
74
|
+
__metadata("design:type", Function),
|
|
75
|
+
__metadata("design:paramtypes", [String]),
|
|
76
|
+
__metadata("design:returntype", void 0)
|
|
77
|
+
], I18n.prototype, "_onLanguageChangedRequestedUnsafe", null);
|
|
78
|
+
exports.I18n = I18n = I18n_1 = __decorate([
|
|
65
79
|
(0, injection_js_1.Injectable)()
|
|
66
80
|
], I18n);
|
|
@@ -4,13 +4,18 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var I18n_1;
|
|
11
|
+
import { APP_INITIALIZER, EVENT_DIRECTIONS, EventListener } from '@armoury/fivem-framework-common';
|
|
8
12
|
import Polyglot from 'node-polyglot';
|
|
9
13
|
import { Injectable } from 'injection-js';
|
|
10
|
-
let I18n = class I18n {
|
|
14
|
+
let I18n = I18n_1 = class I18n {
|
|
11
15
|
static withOptions(options = {}) {
|
|
12
16
|
var _a;
|
|
13
|
-
const language = (_a =
|
|
17
|
+
const language = (_a = (Cfx.Client.GetResourceKvpString('armoury:language')
|
|
18
|
+
|| options.defaultLanguage)) !== null && _a !== void 0 ? _a : 'en-US';
|
|
14
19
|
return {
|
|
15
20
|
provide: APP_INITIALIZER,
|
|
16
21
|
useValue: () => this.loadLanguage(language),
|
|
@@ -44,17 +49,26 @@ let I18n = class I18n {
|
|
|
44
49
|
console.warn(`Language not found: ${language}`);
|
|
45
50
|
}
|
|
46
51
|
}
|
|
47
|
-
console.log('translations are', translations);
|
|
48
52
|
this.polyglot.locale(language);
|
|
49
53
|
this.polyglot.replace(translations);
|
|
50
54
|
}
|
|
51
55
|
static translate(key, params = {}) {
|
|
52
|
-
console.log('translate() called! key:', key, 'params:', params);
|
|
53
56
|
return this.polyglot.t(key, params);
|
|
54
57
|
}
|
|
58
|
+
_onLanguageChangedRequestedUnsafe(language) {
|
|
59
|
+
console.log(`Setting language to ${language}.`);
|
|
60
|
+
Cfx.Client.SetResourceKvp('armoury:language', language);
|
|
61
|
+
I18n_1.setLanguage(language);
|
|
62
|
+
}
|
|
55
63
|
};
|
|
56
64
|
I18n.polyglot = new Polyglot();
|
|
57
|
-
|
|
65
|
+
__decorate([
|
|
66
|
+
EventListener({ eventName: 'armoury:unsafe:language:change:request', direction: EVENT_DIRECTIONS.CLIENT_TO_CLIENT }),
|
|
67
|
+
__metadata("design:type", Function),
|
|
68
|
+
__metadata("design:paramtypes", [String]),
|
|
69
|
+
__metadata("design:returntype", void 0)
|
|
70
|
+
], I18n.prototype, "_onLanguageChangedRequestedUnsafe", null);
|
|
71
|
+
I18n = I18n_1 = __decorate([
|
|
58
72
|
Injectable()
|
|
59
73
|
], I18n);
|
|
60
74
|
export { I18n };
|
|
@@ -5,6 +5,7 @@ export declare class I18n {
|
|
|
5
5
|
static setLanguage(language: string): void;
|
|
6
6
|
private static loadLanguage;
|
|
7
7
|
static translate(key: string, params?: TranslationParams): string;
|
|
8
|
+
protected _onLanguageChangedRequestedUnsafe(language: string): void;
|
|
8
9
|
}
|
|
9
10
|
type I18nOptions = {
|
|
10
11
|
defaultLanguage?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@armoury/fivem-framework-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.53",
|
|
4
4
|
"description": "Client APIs for the Armoury FiveM framework",
|
|
5
5
|
"main": "dist/cjs/client/index.js",
|
|
6
6
|
"module": "dist/esm/client/index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"rxjs": "^7.8.1"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@armoury/fivem-framework-common": "1.0.
|
|
30
|
+
"@armoury/fivem-framework-common": "1.0.53",
|
|
31
31
|
"node-polyglot": "2.6.0"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|