@jjlmoya/utils-babies 1.7.0 → 1.8.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.
- package/package.json +1 -1
- package/src/tests/slug_uniqueness.test.ts +81 -0
- package/src/tool/baby-feeding-calculator/i18n/ja.ts +1 -1
- package/src/tool/baby-feeding-calculator/i18n/ko.ts +1 -1
- package/src/tool/baby-feeding-calculator/i18n/zh.ts +1 -1
- package/src/tool/baby-percentile-calculator/i18n/ja.ts +1 -1
- package/src/tool/baby-percentile-calculator/i18n/ko.ts +1 -1
- package/src/tool/baby-percentile-calculator/i18n/zh.ts +1 -1
- package/src/tool/pregnancy-calculator/i18n/ja.ts +1 -1
- package/src/tool/pregnancy-calculator/i18n/ko.ts +1 -1
- package/src/tool/pregnancy-calculator/i18n/zh.ts +1 -1
- package/src/tool/vaccination-calendar/i18n/ja.ts +1 -1
- package/src/tool/vaccination-calendar/i18n/ko.ts +1 -1
- package/src/tool/vaccination-calendar/i18n/zh.ts +1 -1
package/package.json
CHANGED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { ALL_TOOLS } from '../tools';
|
|
3
|
+
import type { ToolLocaleContent } from '../types';
|
|
4
|
+
|
|
5
|
+
const sharingLocales = ['ja', 'ko', 'zh'];
|
|
6
|
+
|
|
7
|
+
interface ValidateParams {
|
|
8
|
+
toolId: string;
|
|
9
|
+
locale: string;
|
|
10
|
+
content: ToolLocaleContent;
|
|
11
|
+
enSlug: string;
|
|
12
|
+
slugs: Map<string, string>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const validateLocaleSlug = ({
|
|
16
|
+
toolId,
|
|
17
|
+
locale,
|
|
18
|
+
content,
|
|
19
|
+
enSlug,
|
|
20
|
+
slugs,
|
|
21
|
+
}: ValidateParams) => {
|
|
22
|
+
expect(
|
|
23
|
+
content.slug,
|
|
24
|
+
`Tool "${toolId}" locale "${locale}" has an invalid slug ("${content.slug}"). Slugs must be transliterated (only a-z, 0-9, and -).`,
|
|
25
|
+
).toMatch(/^[a-z0-9-]+$/);
|
|
26
|
+
|
|
27
|
+
if (locale === 'en') {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (sharingLocales.includes(locale)) {
|
|
32
|
+
expect(
|
|
33
|
+
content.slug,
|
|
34
|
+
`Tool "${toolId}" locale "${locale}" must use the same slug as "en" ("${enSlug}").`,
|
|
35
|
+
).toBe(enSlug);
|
|
36
|
+
} else {
|
|
37
|
+
expect(
|
|
38
|
+
content.slug,
|
|
39
|
+
`Tool "${toolId}" locale "${locale}" has the same slug as "en" ("${enSlug}"). Cada slug tiene que estar en su propia idioma`,
|
|
40
|
+
).not.toBe(enSlug);
|
|
41
|
+
|
|
42
|
+
if (slugs.has(content.slug)) {
|
|
43
|
+
const previousLocale = slugs.get(content.slug);
|
|
44
|
+
expect(
|
|
45
|
+
false,
|
|
46
|
+
`Tool "${toolId}" locales "${locale}" and "${previousLocale}" share the same slug ("${content.slug}"). Cada slug tiene que estar en su propia idioma`,
|
|
47
|
+
).toBe(true);
|
|
48
|
+
}
|
|
49
|
+
slugs.set(content.slug, locale);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
describe('Slug Localization and Uniqueness Validation', () => {
|
|
54
|
+
ALL_TOOLS.forEach((tool) => {
|
|
55
|
+
describe(`Tool: ${tool.entry.id}`, () => {
|
|
56
|
+
it('every locale should have a unique, translated slug', async () => {
|
|
57
|
+
const slugs = new Map<string, string>();
|
|
58
|
+
const locales = Object.keys(tool.entry.i18n);
|
|
59
|
+
|
|
60
|
+
let enSlug = '';
|
|
61
|
+
if (locales.includes('en')) {
|
|
62
|
+
const enLoader = tool.entry.i18n['en' as keyof typeof tool.entry.i18n];
|
|
63
|
+
const enContent = (await enLoader?.()) as ToolLocaleContent;
|
|
64
|
+
enSlug = enContent.slug;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
for (const locale of locales) {
|
|
68
|
+
const loader = tool.entry.i18n[locale as keyof typeof tool.entry.i18n];
|
|
69
|
+
const content = (await loader?.()) as ToolLocaleContent;
|
|
70
|
+
validateLocaleSlug({
|
|
71
|
+
toolId: tool.entry.id,
|
|
72
|
+
locale,
|
|
73
|
+
content,
|
|
74
|
+
enSlug,
|
|
75
|
+
slugs,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BabyFeedingCalculatorLocaleContent } from '../index';
|
|
2
2
|
import type { WithContext, FAQPage, HowTo, SoftwareApplication } from 'schema-dts';
|
|
3
3
|
|
|
4
|
-
const slug = '
|
|
4
|
+
const slug = 'baby-feeding-calculator';
|
|
5
5
|
const title = '赤ちゃんの授乳計算機';
|
|
6
6
|
const description = '体重と月齢に基づいて、赤ちゃんがどれだけのミルクを必要としているかを計算します。推奨される授乳回数、1回あたりのミリリットル、空腹と満腹のサイン。';
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BabyFeedingCalculatorLocaleContent } from '../index';
|
|
2
2
|
import type { WithContext, FAQPage, HowTo, SoftwareApplication } from 'schema-dts';
|
|
3
3
|
|
|
4
|
-
const slug = '
|
|
4
|
+
const slug = 'baby-feeding-calculator';
|
|
5
5
|
const title = '아기 수유 계산기';
|
|
6
6
|
const description = '몸무게와 월령에 따라 아기에게 필요한 수유량을 계산합니다. 권장 수유 횟수, 1회당 수유량(ml), 그리고 배고픔과 포만감의 신호.';
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BabyFeedingCalculatorLocaleContent } from '../index';
|
|
2
2
|
import type { WithContext, FAQPage, HowTo, SoftwareApplication } from 'schema-dts';
|
|
3
3
|
|
|
4
|
-
const slug = '
|
|
4
|
+
const slug = 'baby-feeding-calculator';
|
|
5
5
|
const title = '婴儿喂养计算器';
|
|
6
6
|
const description = '根据宝宝的体重和月龄计算其需要的奶量。推荐喂养次数、每餐毫升数以及饥饿和饱腹信号。';
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BabyPercentileCalculatorLocaleContent } from '../index';
|
|
2
2
|
import type { WithContext, FAQPage, HowTo, SoftwareApplication } from 'schema-dts';
|
|
3
3
|
|
|
4
|
-
const slug = 'baby-
|
|
4
|
+
const slug = 'baby-weight-height-percentile';
|
|
5
5
|
const title = 'WHO乳幼児成長曲線(パーセンタイル)計算機';
|
|
6
6
|
const description = 'WHO(世界保健機関)の成長曲線(0〜5歳)に基づき、赤ちゃんの体重、身長、BMIのパーセンタイルを計算します。';
|
|
7
7
|
const faq = [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BabyPercentileCalculatorLocaleContent } from '../index';
|
|
2
2
|
import type { WithContext, FAQPage, HowTo, SoftwareApplication } from 'schema-dts';
|
|
3
3
|
|
|
4
|
-
const slug = 'baby-
|
|
4
|
+
const slug = 'baby-weight-height-percentile';
|
|
5
5
|
const title = 'WHO 영유아 성장도표(백분위) 계산기';
|
|
6
6
|
const description = 'WHO(세계보건기구) 성장도표(0-5세)를 기준으로 아기의 체중, 신장, BMI 백분위를 계산합니다.';
|
|
7
7
|
const faq = [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BabyPercentileCalculatorLocaleContent } from '../index';
|
|
2
2
|
import type { WithContext, FAQPage, HowTo, SoftwareApplication } from 'schema-dts';
|
|
3
3
|
|
|
4
|
-
const slug = 'baby-
|
|
4
|
+
const slug = 'baby-weight-height-percentile';
|
|
5
5
|
const title = 'WHO婴儿成长曲线(百分位)计算器';
|
|
6
6
|
const description = '根据世卫组织(WHO)成长标准(0-5岁)计算宝宝的体重、身长和BMI百分位数。';
|
|
7
7
|
const faq = [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PregnancyCalculatorLocaleContent } from '../index';
|
|
2
2
|
import type { WithContext, FAQPage, HowTo, SoftwareApplication } from 'schema-dts';
|
|
3
3
|
|
|
4
|
-
const slug = '
|
|
4
|
+
const slug = 'pregnancy-weeks-calculator';
|
|
5
5
|
const title = '妊娠週数計算・出産予定日カレンダー';
|
|
6
6
|
const description = '現在の妊娠週数、期(初期・中期・後期)、および出産予定日を正確に計算します。';
|
|
7
7
|
const faq = [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PregnancyCalculatorLocaleContent } from '../index';
|
|
2
2
|
import type { WithContext, FAQPage, HowTo, SoftwareApplication } from 'schema-dts';
|
|
3
3
|
|
|
4
|
-
const slug = '
|
|
4
|
+
const slug = 'pregnancy-weeks-calculator';
|
|
5
5
|
const title = '임신 주수 계산기 및 출산 예정일';
|
|
6
6
|
const description = '현재 임신 몇 주차인지, 분기별 상태, 그리고 출산 예정일을 정확하게 계산해 보세요.';
|
|
7
7
|
const faq = [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PregnancyCalculatorLocaleContent } from '../index';
|
|
2
2
|
import type { WithContext, FAQPage, HowTo, SoftwareApplication } from 'schema-dts';
|
|
3
3
|
|
|
4
|
-
const slug = '
|
|
4
|
+
const slug = 'pregnancy-weeks-calculator';
|
|
5
5
|
const title = '怀孕周数计算器・预产期查询';
|
|
6
6
|
const description = '精确计算您的当前怀孕周数、所处孕期(早期、中期或晚期)以及您的预产期。';
|
|
7
7
|
const faq = [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { VaccinationCalendarLocaleContent } from '../index';
|
|
2
2
|
import type { WithContext, FAQPage, HowTo, SoftwareApplication } from 'schema-dts';
|
|
3
3
|
|
|
4
|
-
const slug = '
|
|
4
|
+
const slug = 'baby-vaccination-calendar-spain';
|
|
5
5
|
const title = 'スペインの予防接種スケジュール計算';
|
|
6
6
|
const description = 'AEP 2026スケジュールに基づき、お子様の予防接種日を正確に計算します。';
|
|
7
7
|
const faq = [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { VaccinationCalendarLocaleContent } from '../index';
|
|
2
2
|
import type { WithContext, FAQPage, HowTo, SoftwareApplication } from 'schema-dts';
|
|
3
3
|
|
|
4
|
-
const slug = '
|
|
4
|
+
const slug = 'baby-vaccination-calendar-spain';
|
|
5
5
|
const title = '스페인 영유아 예방접종 일정표';
|
|
6
6
|
const description = 'AEP 2026 일정에 따라 아기의 정확한 예방접종 날짜를 계산해 보세요.';
|
|
7
7
|
const faq = [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { VaccinationCalendarLocaleContent } from '../index';
|
|
2
2
|
import type { WithContext, FAQPage, HowTo, SoftwareApplication } from 'schema-dts';
|
|
3
3
|
|
|
4
|
-
const slug = '
|
|
4
|
+
const slug = 'baby-vaccination-calendar-spain';
|
|
5
5
|
const title = '西班牙儿童疫苗接种时间表';
|
|
6
6
|
const description = '根据 AEP 2026 最新标准,精确计算您宝宝的疫苗接种日期。';
|
|
7
7
|
const faq = [
|