Skip to content

Commit

Permalink
feat(note): support he-IL, es-ES, fr-FR, cs-CZ, ar-SA langs
Browse files Browse the repository at this point in the history
  • Loading branch information
martyanovandrey committed Feb 1, 2024
1 parent 124211b commit 6e04bfe
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 16 deletions.
44 changes: 44 additions & 0 deletions src/transform/plugins/notes/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
export const titles: Record<string, Record<string, string>> = {
ru: {
info: 'Примечание',
tip: 'Совет',
alert: 'Внимание',
warning: 'Важно',
},
en: {
info: 'Note',
tip: 'Tip',
alert: 'Alert',
warning: 'Warning',
},
ar: {
info: 'ملاحظة',
tip: 'نصيحة',
alert: 'انتباه',
warning: 'هام',
},
cs: {
info: 'Poznámka',
tip: 'Tip',
alert: 'Upozornění',
warning: 'Varování',
},
fr: {
info: 'Remarque',
tip: 'Astuce',
alert: 'Alerte',
warning: 'Avertissement',
},
es: {
info: 'Nota',
tip: 'Consejo',
alert: 'Alerta',
warning: 'Aviso',
},
he: {
info: 'מידע',
tip: 'טיפ',
alert: 'התראה',
warning: 'אזהרה',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,11 @@ import Token from 'markdown-it/lib/token';
import {MarkdownItPluginCb} from './typings';

import {MatchTokenFunction, nestedCloseTokenIdxFactory as closeTokenFactory} from './utils';
import {titles} from "./constants";

Check failure on line 7 in src/transform/plugins/notes/index.ts

View workflow job for this annotation

GitHub Actions / Verify Files

Replace `"./constants"` with `'./constants'`

const ALERT_RE = /^{% note (alert|info|tip|warning)\s*(?:"(.*?)")? %}$/;
const WRONG_NOTES = /^{% note (.*)%}/;

const titles: Record<string, Record<string, string>> = {
ru: {
info: 'Примечание',
tip: 'Совет',
alert: 'Внимание',
warning: 'Важно',
},
en: {
info: 'Note',
tip: 'Tip',
alert: 'Alert',
warning: 'Warning',
},
};

function getTitle(type: string, originLang: keyof typeof titles) {
let lang = originLang;

Expand Down
2 changes: 1 addition & 1 deletion src/transform/plugins/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {MarkdownIt} from '../typings';
export interface MarkdownItPluginOpts {
path: string;
log: Logger;
lang: 'ru' | 'en';
lang: 'ru' | 'en' | 'es' | 'fr' | 'cs' | 'ar' | 'he';
root: string;
isLintRun: boolean;
}
Expand Down

0 comments on commit 6e04bfe

Please sign in to comment.