cozy-client 33.0.7 → 33.1.0
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/dist/CozyClient.js +1 -1
- package/dist/models/document/emojiCountry.js +21 -0
- package/dist/models/document/emojiCountry.spec.js +26 -0
- package/dist/models/document/locales/en.json +3 -0
- package/dist/models/document/locales/fr.json +3 -0
- package/dist/models/document/locales/index.js +8 -3
- package/dist/models/document/locales/index.spec.js +21 -0
- package/package.json +3 -3
- package/types/models/document/emojiCountry.d.ts +1 -0
- package/types/models/document/locales/index.d.ts +2 -3
package/dist/CozyClient.js
CHANGED
|
@@ -2645,7 +2645,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2645
2645
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
2646
2646
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
2647
2647
|
|
|
2648
|
-
CozyClient.version = "33.0
|
|
2648
|
+
CozyClient.version = "33.1.0";
|
|
2649
2649
|
|
|
2650
2650
|
_microee.default.mixin(CozyClient);
|
|
2651
2651
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getEmojiByCountry = void 0;
|
|
7
|
+
var emojiCountry = {
|
|
8
|
+
fr: '🇫🇷'
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* @param {string} country - fr, en, etc
|
|
12
|
+
* @param {Function} t - Translation function
|
|
13
|
+
* @returns {string} - Emoji of country
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
var getEmojiByCountry = function getEmojiByCountry(country, t) {
|
|
17
|
+
if (country === 'stranger') return t('country.stranger');
|
|
18
|
+
return emojiCountry[country];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.getEmojiByCountry = getEmojiByCountry;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getEmojiByCountry } from './emojiCountry'
|
|
2
|
+
|
|
3
|
+
describe('getEmojiByCountry', () => {
|
|
4
|
+
const mockT = jest.fn(key => key)
|
|
5
|
+
it('should return fr flag', () => {
|
|
6
|
+
const res = getEmojiByCountry('fr', mockT)
|
|
7
|
+
|
|
8
|
+
expect(res).toBe('🇫🇷')
|
|
9
|
+
})
|
|
10
|
+
it('should return "stranger" string (key: country.stranger)', () => {
|
|
11
|
+
const mockT = jest.fn(key => key)
|
|
12
|
+
const res = getEmojiByCountry('stranger', mockT)
|
|
13
|
+
|
|
14
|
+
expect(res).toBe('country.stranger')
|
|
15
|
+
})
|
|
16
|
+
it('should return "undefined" if the country is not "fr"', () => {
|
|
17
|
+
const res = getEmojiByCountry('en', mockT)
|
|
18
|
+
|
|
19
|
+
expect(res).toBe(undefined)
|
|
20
|
+
})
|
|
21
|
+
it('should return "undefined" if the country is undefined', () => {
|
|
22
|
+
const res = getEmojiByCountry(undefined, mockT)
|
|
23
|
+
|
|
24
|
+
expect(res).toBe(undefined)
|
|
25
|
+
})
|
|
26
|
+
})
|
|
@@ -9,6 +9,8 @@ exports.getBoundT = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _nodePolyglot = _interopRequireDefault(require("node-polyglot"));
|
|
11
11
|
|
|
12
|
+
var _emojiCountry = require("../emojiCountry");
|
|
13
|
+
|
|
12
14
|
var polyglots = {};
|
|
13
15
|
var langs = ['fr', 'en'];
|
|
14
16
|
|
|
@@ -26,15 +28,18 @@ for (var _i = 0, _langs = langs; _i < _langs.length; _i++) {
|
|
|
26
28
|
polyglots[lang] = polyglot;
|
|
27
29
|
}
|
|
28
30
|
/**
|
|
29
|
-
*
|
|
30
31
|
* @param {string} lang - fr, en, etc
|
|
31
|
-
* @returns {(
|
|
32
|
+
* @returns {(label: string, country?: string) => string}
|
|
32
33
|
*/
|
|
33
34
|
|
|
34
35
|
|
|
35
36
|
var getBoundT = function getBoundT(lang) {
|
|
36
37
|
var polyglot = polyglots[lang] || polyglots['en'];
|
|
37
|
-
|
|
38
|
+
var t = polyglot.t.bind(polyglot);
|
|
39
|
+
return function (label, country) {
|
|
40
|
+
var emojiCountry = (0, _emojiCountry.getEmojiByCountry)(country, t);
|
|
41
|
+
return emojiCountry ? "".concat(t(label), " (").concat(emojiCountry, ")") : t(label);
|
|
42
|
+
};
|
|
38
43
|
};
|
|
39
44
|
|
|
40
45
|
exports.getBoundT = getBoundT;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getBoundT } from './index'
|
|
2
|
+
|
|
3
|
+
describe('getBoundT', () => {
|
|
4
|
+
const t = getBoundT('en')
|
|
5
|
+
|
|
6
|
+
it('should return "ID card" without suffix', () => {
|
|
7
|
+
const res = t('Scan.items.national_id_card')
|
|
8
|
+
|
|
9
|
+
expect(res).toBe('ID card')
|
|
10
|
+
})
|
|
11
|
+
it('should return "ID card" with "(Stranger)" suffix', () => {
|
|
12
|
+
const res = t('Scan.items.national_id_card', 'stranger')
|
|
13
|
+
|
|
14
|
+
expect(res).toBe('ID card (Stranger)')
|
|
15
|
+
})
|
|
16
|
+
it('should return "ID card" with "🇫🇷" suffix', () => {
|
|
17
|
+
const res = t('Scan.items.national_id_card', 'fr')
|
|
18
|
+
|
|
19
|
+
expect(res).toBe('ID card (🇫🇷)')
|
|
20
|
+
})
|
|
21
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "33.0
|
|
3
|
+
"version": "33.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.node.js",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@types/jest": "^26.0.20",
|
|
19
19
|
"@types/lodash": "^4.14.170",
|
|
20
20
|
"btoa": "^1.2.1",
|
|
21
|
-
"cozy-stack-client": "^33.0.
|
|
21
|
+
"cozy-stack-client": "^33.0.8",
|
|
22
22
|
"json-stable-stringify": "^1.0.1",
|
|
23
23
|
"lodash": "^4.17.13",
|
|
24
24
|
"microee": "^0.0.6",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
|
|
74
74
|
},
|
|
75
75
|
"sideEffects": false,
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "93c1ef7d6bd6607b4d2d43edd9bb19c8f59a53c8"
|
|
77
77
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function getEmojiByCountry(country: string, t: Function): string;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
2
|
* @param {string} lang - fr, en, etc
|
|
4
|
-
* @returns {(
|
|
3
|
+
* @returns {(label: string, country?: string) => string}
|
|
5
4
|
*/
|
|
6
|
-
export function getBoundT(lang: string): (
|
|
5
|
+
export function getBoundT(lang: string): (label: string, country?: string) => string;
|