Skip to content

Commit

Permalink
change delimiter
Browse files Browse the repository at this point in the history
  • Loading branch information
while1618 committed Jun 26, 2024
1 parent eed16cb commit df4aaf0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/translate/translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { JSONObj } from './payload';
import { replaceAll } from './util';

export abstract class Translate {
public static readonly sentenceDelimiter: string = '\n{~~~}\n';
public static readonly sentenceDelimiter: string = '\n#__#\n';
private static readonly skipWordRegex: RegExp =
/({{([^{}]+)}}|<([^<>]+)>|<\/([^<>]+)>|\{([^{}]+)\})/g;
private static readonly maxLinesPerRequest = 200;
Expand Down Expand Up @@ -181,8 +181,8 @@ export abstract class Translate {
private saveTranslation = (value: string, originalObject: JSONObj, saveTo: string): void => {
// replaceAll() is used because of weird bug that sometimes happens
// when translate api return delimiter with space in between
let translations = replaceAll(value, '{~~~ }', '{~~~}');
translations = replaceAll(translations, '{ ~~~}', '{~~~}');
let translations = replaceAll(value, '#__ #', '#__#');
translations = replaceAll(translations, '# __#', '#__#');
let content: JSONObj = this.createTranslatedObject(
translations.split(Translate.sentenceDelimiter.trim()),
originalObject,
Expand Down

0 comments on commit df4aaf0

Please sign in to comment.