@discord/intl 0.10.4 → 0.11.1-rc.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.
@@ -46,6 +46,8 @@ class IntlManager {
46
46
  makeFormatFunction({ format, builder, }) {
47
47
  const formatter = format.bind(this);
48
48
  return (message, values) => {
49
+ if (message == null)
50
+ return null;
49
51
  return formatter(message(this.currentLocale), values, builder);
50
52
  };
51
53
  }
@@ -68,6 +70,8 @@ class IntlManager {
68
70
  * immediately return the plain string value of the message in the current locale.
69
71
  */
70
72
  string(message) {
73
+ if (message == null)
74
+ return '';
71
75
  return message(this.currentLocale).reserialize();
72
76
  }
73
77
  /**
@@ -80,6 +84,8 @@ class IntlManager {
80
84
  * applications that do their own message parsing.
81
85
  */
82
86
  reserialize(message) {
87
+ if (message == null)
88
+ return '';
83
89
  const resolved = message(this.currentLocale);
84
90
  if (typeof resolved === 'string')
85
91
  return resolved;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@discord/intl",
3
- "version": "0.10.4",
3
+ "version": "0.11.1-rc.0",
4
4
  "license": "MIT",
5
5
  "description": "Client runtime for managing messages and translations in a React project.",
6
6
  "main": "./dist/index.js",
@@ -23,7 +23,7 @@
23
23
  "@formatjs/intl": "^2.10.1",
24
24
  "@intrnl/xxhash64": "^0.1.2",
25
25
  "intl-messageformat": "^10.5.11",
26
- "@discord/intl-ast": "0.10.4"
26
+ "@discord/intl-ast": "0.11.1-rc.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@swc/cli": "^0.3.12",
@@ -104,6 +104,7 @@ export class IntlManager {
104
104
  }: F): FormatFunction<FormatterReturnType<F>> {
105
105
  const formatter = format.bind(this);
106
106
  return (message, values) => {
107
+ if (message == null) return null;
107
108
  return formatter(message(this.currentLocale), values, builder);
108
109
  };
109
110
  }
@@ -137,6 +138,7 @@ export class IntlManager {
137
138
  * immediately return the plain string value of the message in the current locale.
138
139
  */
139
140
  string<T extends TypedIntlMessageGetter<{}>>(message: T): string {
141
+ if (message == null) return '';
140
142
  return message(this.currentLocale).reserialize();
141
143
  }
142
144
 
@@ -150,6 +152,8 @@ export class IntlManager {
150
152
  * applications that do their own message parsing.
151
153
  */
152
154
  reserialize<T extends IntlMessageGetter>(message: T): string {
155
+ if (message == null) return '';
156
+
153
157
  const resolved = message(this.currentLocale);
154
158
  if (typeof resolved === 'string') return resolved;
155
159
  return resolved.reserialize();