File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import type { GeneratorOptions } from "@babel/core" ;
22
3- export const UNICODE_REGEX : RegExp
43export declare type CatalogFormat = "lingui" | "minimal" | "po" | "csv" | "po-gettext" ;
54export type CatalogFormatOptions = {
65 origins ?: boolean ;
Original file line number Diff line number Diff line change @@ -4,9 +4,7 @@ import fs from "fs"
44import chalk from "chalk"
55import { cosmiconfigSync } from "cosmiconfig"
66import { multipleValidOptions , validate } from "jest-validate"
7- // This regex will detect if a string contains unicode chars, when they're we should interpolate them
8- // why? because platforms like react native doesn't parse them, just doing a JSON.parse makes them UTF-8 friendly
9- export const UNICODE_REGEX = / \\ u [ a - f A - F 0 - 9 ] { 4 } | \\ x [ a - f A - F 0 - 9 ] { 2 } / g;
7+
108export type CatalogFormat = "lingui" | "minimal" | "po" | "csv"
119
1210export type CatalogFormatOptions = {
Original file line number Diff line number Diff line change 11import * as R from "ramda"
22import * as babelTypes from "@babel/types"
33import { NodePath } from "@babel/traverse"
4- import { UNICODE_REGEX } from "@lingui/conf"
54
65import ICUMessageFormat from "./icu"
76import { zip , makeCounter } from "./utils"
@@ -266,7 +265,9 @@ export default class MacroJs {
266265 quasis : R . map ( ( text : babelTypes . TemplateElement ) => {
267266 // Don't output tokens without text.
268267 // if it's an unicode we keep the cooked value because it's the parsed value by babel (without unicode chars)
269- const value = UNICODE_REGEX . test ( text . value . raw ) ? text . value . cooked : text . value . raw
268+ // This regex will detect if a string contains unicode chars, when they're we should interpolate them
269+ // why? because platforms like react native doesn't parse them, just doing a JSON.parse makes them UTF-8 friendly
270+ const value = / \\ u [ a - f A - F 0 - 9 ] { 4 } | \\ x [ a - f A - F 0 - 9 ] { 2 } / g. test ( text . value . raw ) ? text . value . cooked : text . value . raw
270271 if ( value === "" ) return null
271272
272273 return {
Original file line number Diff line number Diff line change 11import * as R from "ramda"
22import * as babelTypes from "@babel/types"
33import { NodePath } from "@babel/traverse"
4- import { UNICODE_REGEX } from "@lingui/conf"
54
65import ICUMessageFormat from "./icu"
76import { zip , makeCounter } from "./utils"
@@ -231,8 +230,10 @@ export default class MacroJSX {
231230 // Don"t output tokens without text.
232231 R . evolve ( {
233232 quasis : R . map ( ( text : babelTypes . TemplateElement ) => {
234- // Don"t output tokens without text.
235- const value = UNICODE_REGEX . test ( text . value . raw ) ? text . value . cooked : text . value . raw
233+ // if it's an unicode we keep the cooked value because it's the parsed value by babel (without unicode chars)
234+ // This regex will detect if a string contains unicode chars, when they're we should interpolate them
235+ // why? because platforms like react native doesn't parse them, just doing a JSON.parse makes them UTF-8 friendly
236+ const value = / \\ u [ a - f A - F 0 - 9 ] { 4 } | \\ x [ a - f A - F 0 - 9 ] { 2 } / g. test ( text . value . raw ) ? text . value . cooked : text . value . raw
236237 if ( value === "" ) return null
237238
238239 return this . tokenizeText ( this . clearBackslashes ( value ) )
You can’t perform that action at this time.
0 commit comments