Skip to content

Commit

Permalink
Use rich library
Browse files Browse the repository at this point in the history
  • Loading branch information
askvortsov1 committed Apr 18, 2021
1 parent e837986 commit 9d5d950
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
3 changes: 2 additions & 1 deletion js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"private": true,
"name": "@flarum/core",
"dependencies": {
"@ultraq/icu-message-formatter": "git+https://github.com/askvortsov1/icu-message-formatter.git",
"@askvortsov/rich-icu-message-formatter": "^0.1.0",
"@ultraq/icu-message-formatter": "^0.10.0",
"bootstrap": "^3.4.1",
"clsx": "^1.1.1",
"color-thief-browser": "^2.0.2",
Expand Down
14 changes: 3 additions & 11 deletions js/src/common/Translator.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
import { MessageFormatter, pluralTypeHandler, selectTypeHandler } from '@ultraq/icu-message-formatter';
import { RichMessageFormatter } from '@askvortsov/rich-icu-message-formatter';
import { pluralTypeHandler, selectTypeHandler } from '@ultraq/icu-message-formatter';
import username from './helpers/username';
import extract from './utils/extract';

const fillTags = (tag, tags, children) => {
if (tag in tags) {
tags[tag].children = m.fragment(children).children;
return tags[tag];
}

return children;
};

export default class Translator {
constructor() {
/**
Expand All @@ -21,7 +13,7 @@ export default class Translator {
*/
this.translations = {};

this.formatter = new MessageFormatter(null, this.formatterTypeHandlers(), fillTags);
this.formatter = new RichMessageFormatter(null, this.formatterTypeHandlers(), fillTags);
}

formatterTypeHandlers() {
Expand Down

0 comments on commit 9d5d950

Please sign in to comment.