@intlayer/docs 7.5.12 → 7.5.14
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/blog/ar/per-component_vs_centralized_i18n.md +248 -0
- package/blog/de/per-component_vs_centralized_i18n.md +248 -0
- package/blog/en/_per-component_vs_centralized_i18n.md +252 -0
- package/blog/en/per-component_vs_centralized_i18n.md +248 -0
- package/blog/en-GB/per-component_vs_centralized_i18n.md +247 -0
- package/blog/es/per-component_vs_centralized_i18n.md +245 -0
- package/blog/fr/per-component_vs_centralized_i18n.md +245 -0
- package/blog/hi/per-component_vs_centralized_i18n.md +249 -0
- package/blog/id/per-component_vs_centralized_i18n.md +248 -0
- package/blog/it/per-component_vs_centralized_i18n.md +247 -0
- package/blog/ja/per-component_vs_centralized_i18n.md +247 -0
- package/blog/ko/per-component_vs_centralized_i18n.md +246 -0
- package/blog/pl/per-component_vs_centralized_i18n.md +247 -0
- package/blog/pt/per-component_vs_centralized_i18n.md +246 -0
- package/blog/ru/per-component_vs_centralized_i18n.md +251 -0
- package/blog/tr/per-component_vs_centralized_i18n.md +244 -0
- package/blog/uk/compiler_vs_declarative_i18n.md +224 -0
- package/blog/uk/i18n_using_next-i18next.md +1086 -0
- package/blog/uk/i18n_using_next-intl.md +760 -0
- package/blog/uk/index.md +69 -0
- package/blog/uk/internationalization_and_SEO.md +273 -0
- package/blog/uk/intlayer_with_i18next.md +211 -0
- package/blog/uk/intlayer_with_next-i18next.md +202 -0
- package/blog/uk/intlayer_with_next-intl.md +203 -0
- package/blog/uk/intlayer_with_react-i18next.md +200 -0
- package/blog/uk/intlayer_with_react-intl.md +202 -0
- package/blog/uk/intlayer_with_vue-i18n.md +206 -0
- package/blog/uk/l10n_platform_alternative/Lokalise.md +80 -0
- package/blog/uk/l10n_platform_alternative/crowdin.md +80 -0
- package/blog/uk/l10n_platform_alternative/phrase.md +78 -0
- package/blog/uk/list_i18n_technologies/CMS/drupal.md +143 -0
- package/blog/uk/list_i18n_technologies/CMS/wix.md +167 -0
- package/blog/uk/list_i18n_technologies/CMS/wordpress.md +189 -0
- package/blog/uk/list_i18n_technologies/frameworks/angular.md +125 -0
- package/blog/uk/list_i18n_technologies/frameworks/flutter.md +128 -0
- package/blog/uk/list_i18n_technologies/frameworks/react-native.md +217 -0
- package/blog/uk/list_i18n_technologies/frameworks/react.md +155 -0
- package/blog/uk/list_i18n_technologies/frameworks/svelte.md +145 -0
- package/blog/uk/list_i18n_technologies/frameworks/vue.md +144 -0
- package/blog/uk/next-i18next_vs_next-intl_vs_intlayer.md +1499 -0
- package/blog/uk/nextjs-multilingual-seo-comparison.md +360 -0
- package/blog/uk/per-component_vs_centralized_i18n.md +248 -0
- package/blog/uk/rag_powered_documentation_assistant.md +288 -0
- package/blog/uk/react-i18next_vs_react-intl_vs_intlayer.md +164 -0
- package/blog/uk/vue-i18n_vs_intlayer.md +279 -0
- package/blog/uk/what_is_internationalization.md +167 -0
- package/blog/vi/per-component_vs_centralized_i18n.md +246 -0
- package/blog/zh/per-component_vs_centralized_i18n.md +248 -0
- package/dist/cjs/common.cjs.map +1 -1
- package/dist/cjs/generated/blog.entry.cjs +20 -0
- package/dist/cjs/generated/blog.entry.cjs.map +1 -1
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/cjs/generated/frequentQuestions.entry.cjs +20 -0
- package/dist/cjs/generated/frequentQuestions.entry.cjs.map +1 -1
- package/dist/cjs/generated/legal.entry.cjs.map +1 -1
- package/dist/esm/common.mjs.map +1 -1
- package/dist/esm/generated/blog.entry.mjs +20 -0
- package/dist/esm/generated/blog.entry.mjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/esm/generated/frequentQuestions.entry.mjs +20 -0
- package/dist/esm/generated/frequentQuestions.entry.mjs.map +1 -1
- package/dist/esm/generated/legal.entry.mjs.map +1 -1
- package/dist/types/generated/blog.entry.d.ts +1 -0
- package/dist/types/generated/blog.entry.d.ts.map +1 -1
- package/dist/types/generated/frequentQuestions.entry.d.ts +1 -0
- package/dist/types/generated/frequentQuestions.entry.d.ts.map +1 -1
- package/docs/ar/configuration.md +6 -1
- package/docs/ar/dictionary/content_file.md +6 -1
- package/docs/de/configuration.md +6 -1
- package/docs/de/dictionary/content_file.md +6 -1
- package/docs/en/configuration.md +6 -1
- package/docs/en/dictionary/content_file.md +6 -1
- package/docs/en-GB/configuration.md +6 -1
- package/docs/en-GB/dictionary/content_file.md +3 -1
- package/docs/es/configuration.md +6 -1
- package/docs/es/dictionary/content_file.md +6 -1
- package/docs/fr/configuration.md +6 -1
- package/docs/fr/dictionary/content_file.md +3 -1
- package/docs/hi/configuration.md +6 -1
- package/docs/hi/dictionary/content_file.md +3 -1
- package/docs/id/configuration.md +6 -1
- package/docs/id/dictionary/content_file.md +3 -1
- package/docs/it/configuration.md +6 -1
- package/docs/it/dictionary/content_file.md +3 -1
- package/docs/ja/configuration.md +6 -1
- package/docs/ja/dictionary/content_file.md +3 -1
- package/docs/ko/configuration.md +6 -1
- package/docs/ko/dictionary/content_file.md +3 -1
- package/docs/pl/configuration.md +3 -1
- package/docs/pl/dictionary/content_file.md +3 -1
- package/docs/pt/configuration.md +6 -1
- package/docs/pt/dictionary/content_file.md +3 -1
- package/docs/ru/configuration.md +6 -1
- package/docs/ru/dictionary/content_file.md +6 -1
- package/docs/tr/configuration.md +6 -1
- package/docs/tr/dictionary/content_file.md +3 -1
- package/docs/uk/CI_CD.md +198 -0
- package/docs/uk/autoFill.md +307 -0
- package/docs/uk/bundle_optimization.md +185 -0
- package/docs/uk/cli/build.md +64 -0
- package/docs/uk/cli/ci.md +137 -0
- package/docs/uk/cli/configuration.md +63 -0
- package/docs/uk/cli/debug.md +46 -0
- package/docs/uk/cli/doc-review.md +43 -0
- package/docs/uk/cli/doc-translate.md +132 -0
- package/docs/uk/cli/editor.md +28 -0
- package/docs/uk/cli/fill.md +130 -0
- package/docs/uk/cli/index.md +190 -0
- package/docs/uk/cli/init.md +84 -0
- package/docs/uk/cli/list.md +90 -0
- package/docs/uk/cli/list_projects.md +128 -0
- package/docs/uk/cli/live.md +41 -0
- package/docs/uk/cli/login.md +157 -0
- package/docs/uk/cli/pull.md +78 -0
- package/docs/uk/cli/push.md +98 -0
- package/docs/uk/cli/sdk.md +71 -0
- package/docs/uk/cli/test.md +76 -0
- package/docs/uk/cli/transform.md +65 -0
- package/docs/uk/cli/version.md +24 -0
- package/docs/uk/cli/watch.md +37 -0
- package/docs/uk/configuration.md +742 -0
- package/docs/uk/dictionary/condition.md +237 -0
- package/docs/uk/dictionary/content_file.md +1134 -0
- package/docs/uk/dictionary/enumeration.md +245 -0
- package/docs/uk/dictionary/file.md +232 -0
- package/docs/uk/dictionary/function_fetching.md +212 -0
- package/docs/uk/dictionary/gender.md +273 -0
- package/docs/uk/dictionary/insertion.md +187 -0
- package/docs/uk/dictionary/markdown.md +383 -0
- package/docs/uk/dictionary/nesting.md +273 -0
- package/docs/uk/dictionary/translation.md +332 -0
- package/docs/uk/formatters.md +595 -0
- package/docs/uk/how_works_intlayer.md +256 -0
- package/docs/uk/index.md +175 -0
- package/docs/uk/interest_of_intlayer.md +297 -0
- package/docs/uk/intlayer_CMS.md +569 -0
- package/docs/uk/intlayer_visual_editor.md +292 -0
- package/docs/uk/intlayer_with_angular.md +710 -0
- package/docs/uk/intlayer_with_astro.md +256 -0
- package/docs/uk/intlayer_with_create_react_app.md +1258 -0
- package/docs/uk/intlayer_with_express.md +429 -0
- package/docs/uk/intlayer_with_fastify.md +446 -0
- package/docs/uk/intlayer_with_lynx+react.md +548 -0
- package/docs/uk/intlayer_with_nestjs.md +283 -0
- package/docs/uk/intlayer_with_next-i18next.md +640 -0
- package/docs/uk/intlayer_with_next-intl.md +456 -0
- package/docs/uk/intlayer_with_nextjs_page_router.md +1541 -0
- package/docs/uk/intlayer_with_nuxt.md +711 -0
- package/docs/uk/intlayer_with_react_router_v7.md +600 -0
- package/docs/uk/intlayer_with_react_router_v7_fs_routes.md +669 -0
- package/docs/uk/intlayer_with_svelte_kit.md +579 -0
- package/docs/uk/intlayer_with_tanstack.md +818 -0
- package/docs/uk/intlayer_with_vite+preact.md +1748 -0
- package/docs/uk/intlayer_with_vite+react.md +1449 -0
- package/docs/uk/intlayer_with_vite+solid.md +302 -0
- package/docs/uk/intlayer_with_vite+svelte.md +520 -0
- package/docs/uk/intlayer_with_vite+vue.md +1113 -0
- package/docs/uk/introduction.md +222 -0
- package/docs/uk/locale_mapper.md +242 -0
- package/docs/uk/mcp_server.md +211 -0
- package/docs/uk/packages/express-intlayer/t.md +465 -0
- package/docs/uk/packages/intlayer/getEnumeration.md +159 -0
- package/docs/uk/packages/intlayer/getHTMLTextDir.md +121 -0
- package/docs/uk/packages/intlayer/getLocaleLang.md +81 -0
- package/docs/uk/packages/intlayer/getLocaleName.md +135 -0
- package/docs/uk/packages/intlayer/getLocalizedUrl.md +338 -0
- package/docs/uk/packages/intlayer/getMultilingualUrls.md +359 -0
- package/docs/uk/packages/intlayer/getPathWithoutLocale.md +75 -0
- package/docs/uk/packages/intlayer/getPrefix.md +213 -0
- package/docs/uk/packages/intlayer/getTranslation.md +190 -0
- package/docs/uk/packages/intlayer/getTranslationContent.md +189 -0
- package/docs/uk/packages/next-intlayer/t.md +365 -0
- package/docs/uk/packages/next-intlayer/useDictionary.md +276 -0
- package/docs/uk/packages/next-intlayer/useIntlayer.md +263 -0
- package/docs/uk/packages/next-intlayer/useLocale.md +166 -0
- package/docs/uk/packages/react-intlayer/t.md +311 -0
- package/docs/uk/packages/react-intlayer/useDictionary.md +295 -0
- package/docs/uk/packages/react-intlayer/useI18n.md +250 -0
- package/docs/uk/packages/react-intlayer/useIntlayer.md +251 -0
- package/docs/uk/packages/react-intlayer/useLocale.md +210 -0
- package/docs/uk/per_locale_file.md +345 -0
- package/docs/uk/plugins/sync-json.md +398 -0
- package/docs/uk/readme.md +265 -0
- package/docs/uk/releases/v6.md +305 -0
- package/docs/uk/releases/v7.md +624 -0
- package/docs/uk/roadmap.md +346 -0
- package/docs/uk/testing.md +204 -0
- package/docs/vi/configuration.md +6 -1
- package/docs/vi/dictionary/content_file.md +6 -1
- package/docs/zh/configuration.md +6 -1
- package/docs/zh/dictionary/content_file.md +6 -1
- package/frequent_questions/ar/error-vite-env-only.md +77 -0
- package/frequent_questions/de/error-vite-env-only.md +77 -0
- package/frequent_questions/en/error-vite-env-only.md +77 -0
- package/frequent_questions/en-GB/error-vite-env-only.md +77 -0
- package/frequent_questions/es/error-vite-env-only.md +76 -0
- package/frequent_questions/fr/error-vite-env-only.md +77 -0
- package/frequent_questions/hi/error-vite-env-only.md +77 -0
- package/frequent_questions/id/error-vite-env-only.md +77 -0
- package/frequent_questions/it/error-vite-env-only.md +77 -0
- package/frequent_questions/ja/error-vite-env-only.md +77 -0
- package/frequent_questions/ko/error-vite-env-only.md +77 -0
- package/frequent_questions/pl/error-vite-env-only.md +77 -0
- package/frequent_questions/pt/error-vite-env-only.md +77 -0
- package/frequent_questions/ru/error-vite-env-only.md +77 -0
- package/frequent_questions/tr/error-vite-env-only.md +77 -0
- package/frequent_questions/uk/SSR_Next_no_[locale].md +104 -0
- package/frequent_questions/uk/array_as_content_declaration.md +72 -0
- package/frequent_questions/uk/build_dictionaries.md +58 -0
- package/frequent_questions/uk/build_error_CI_CD.md +74 -0
- package/frequent_questions/uk/bun_set_up.md +53 -0
- package/frequent_questions/uk/customized_locale_list.md +64 -0
- package/frequent_questions/uk/domain_routing.md +113 -0
- package/frequent_questions/uk/error-vite-env-only.md +77 -0
- package/frequent_questions/uk/esbuild_error.md +29 -0
- package/frequent_questions/uk/get_locale_cookie.md +142 -0
- package/frequent_questions/uk/intlayer_command_undefined.md +155 -0
- package/frequent_questions/uk/locale_incorect_in_url.md +73 -0
- package/frequent_questions/uk/package_version_error.md +181 -0
- package/frequent_questions/uk/static_rendering.md +44 -0
- package/frequent_questions/uk/translated_path_url.md +55 -0
- package/frequent_questions/uk/unknown_command.md +97 -0
- package/frequent_questions/vi/error-vite-env-only.md +77 -0
- package/frequent_questions/zh/error-vite-env-only.md +77 -0
- package/legal/uk/privacy_notice.md +83 -0
- package/legal/uk/terms_of_service.md +55 -0
- package/package.json +9 -9
- package/src/generated/blog.entry.ts +20 -0
- package/src/generated/frequentQuestions.entry.ts +20 -0
|
@@ -0,0 +1,710 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2025-04-18
|
|
3
|
+
updatedAt: 2025-12-30
|
|
4
|
+
title: Як перекласти ваш додаток Angular — посібник з i18n 2026
|
|
5
|
+
description: Дізнайтеся, як зробити ваш вебсайт на Angular багатомовним. Слідуйте документації, щоб інтернаціоналізувати (i18n) та перекласти його.
|
|
6
|
+
keywords:
|
|
7
|
+
- Інтернаціоналізація
|
|
8
|
+
- Документація
|
|
9
|
+
- Intlayer
|
|
10
|
+
- Angular
|
|
11
|
+
- JavaScript
|
|
12
|
+
slugs:
|
|
13
|
+
- doc
|
|
14
|
+
- environment
|
|
15
|
+
- angular
|
|
16
|
+
# applicationTemplate: https://github.com/aymericzip/intlayer-angular-template
|
|
17
|
+
history:
|
|
18
|
+
- version: 7.5.9
|
|
19
|
+
date: 2025-12-30
|
|
20
|
+
changes: Додано команду init
|
|
21
|
+
- version: 5.5.10
|
|
22
|
+
date: 2025-06-29
|
|
23
|
+
changes: Ініціалізація історії
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
# Перекладіть ваш вебсайт на Angular за допомогою Intlayer | Інтернаціоналізація (i18n)
|
|
27
|
+
|
|
28
|
+
> Цей пакет знаходиться в розробці. Див. [issue](https://github.com/aymericzip/intlayer/issues/116) для детальнішої інформації. Підтримайте Intlayer для Angular, поставивши лайк цьому issue
|
|
29
|
+
|
|
30
|
+
<!-- Див. [Application Template](https://github.com/aymericzip/intlayer-angular-template) на GitHub. -->
|
|
31
|
+
|
|
32
|
+
## Що таке Intlayer?
|
|
33
|
+
|
|
34
|
+
**Intlayer** — інноваційна, open-source бібліотека для інтернаціоналізації (i18n), створена для спрощення підтримки кількох мов у сучасних вебдодатках.
|
|
35
|
+
|
|
36
|
+
За допомогою Intlayer ви можете:
|
|
37
|
+
|
|
38
|
+
- **Просто керувати перекладами** за допомогою декларативних словників на рівні компонентів.
|
|
39
|
+
- **Динамічно локалізувати метадані, маршрути та вміст.**
|
|
40
|
+
- **Забезпечити підтримку TypeScript** з автоматично згенерованими типами, що покращує автодоповнення та виявлення помилок.
|
|
41
|
+
/// **Отримайте переваги розширених функцій**, таких як динамічне визначення локалі та її перемикання.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Покроковий посібник з налаштування Intlayer у додатку Angular
|
|
46
|
+
|
|
47
|
+
### Крок 1: Встановлення залежностей
|
|
48
|
+
|
|
49
|
+
Встановіть необхідні пакети за допомогою менеджера пакетів:
|
|
50
|
+
|
|
51
|
+
```bash packageManager="npm"
|
|
52
|
+
npm install intlayer angular-intlayer @intlayer/webpack
|
|
53
|
+
npx intlayer init
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```bash packageManager="pnpm"
|
|
57
|
+
pnpm add intlayer angular-intlayer @intlayer/webpack
|
|
58
|
+
pnpm intlayer init
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```bash packageManager="yarn"
|
|
62
|
+
yarn add intlayer angular-intlayer @intlayer/webpack
|
|
63
|
+
yarn intlayer init
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
```bash packageManager="bun"
|
|
67
|
+
bun add intlayer angular-intlayer @intlayer/webpack
|
|
68
|
+
bunx intlayer init
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
- **intlayer**
|
|
72
|
+
|
|
73
|
+
Основний пакет, який надає інструменти інтернаціоналізації для керування конфігурацією, перекладів, [декларації контенту](https://github.com/aymericzip/intlayer/blob/main/docs/docs/uk/dictionary/content_file.md), транспіляції та [CLI-команд](https://github.com/aymericzip/intlayer/blob/main/docs/docs/uk/cli/index.md).
|
|
74
|
+
|
|
75
|
+
- **angular-intlayer**
|
|
76
|
+
Пакет, який інтегрує Intlayer з Angular-застосунком. Забезпечує провайдери контексту та хуки для інтернаціоналізації в Angular.
|
|
77
|
+
|
|
78
|
+
- **@intlayer/webpack**
|
|
79
|
+
|
|
80
|
+
Пакет, який інтегрує Intlayer з Webpack. Використовується Angular CLI для побудови файлів декларації контенту та їх моніторингу в режимі розробки.
|
|
81
|
+
|
|
82
|
+
### Крок 2: Конфігурація вашого проєкту
|
|
83
|
+
|
|
84
|
+
Створіть файл конфігурації для налаштування мов вашого застосунку:
|
|
85
|
+
|
|
86
|
+
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
87
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
88
|
+
|
|
89
|
+
const config: IntlayerConfig = {
|
|
90
|
+
internationalization: {
|
|
91
|
+
locales: [
|
|
92
|
+
Locales.ENGLISH,
|
|
93
|
+
Locales.FRENCH,
|
|
94
|
+
Locales.SPANISH,
|
|
95
|
+
// Ваші інші локалі
|
|
96
|
+
],
|
|
97
|
+
defaultLocale: Locales.ENGLISH,
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export default config;
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
105
|
+
import { Locales } from "intlayer";
|
|
106
|
+
|
|
107
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
108
|
+
const config = {
|
|
109
|
+
internationalization: {
|
|
110
|
+
locales: [
|
|
111
|
+
Locales.ENGLISH,
|
|
112
|
+
Locales.FRENCH,
|
|
113
|
+
Locales.SPANISH,
|
|
114
|
+
// Ваші інші локалі
|
|
115
|
+
],
|
|
116
|
+
defaultLocale: Locales.ENGLISH,
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export default config;
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
124
|
+
const { Locales } = require("intlayer");
|
|
125
|
+
|
|
126
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
127
|
+
const config = {
|
|
128
|
+
internationalization: {
|
|
129
|
+
locales: [
|
|
130
|
+
Locales.ENGLISH,
|
|
131
|
+
Locales.FRENCH,
|
|
132
|
+
Locales.SPANISH,
|
|
133
|
+
// Інші ваші локалі
|
|
134
|
+
],
|
|
135
|
+
defaultLocale: Locales.ENGLISH,
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
module.exports = config;
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
> Через цей файл конфігурації ви можете налаштувати локалізовані URL-адреси, перенаправлення в middleware, назви cookie, розташування та розширення ваших декларацій контенту, вимкнути логування Intlayer у консолі та інше. Для повного переліку доступних параметрів див. [документацію з конфігурації](https://github.com/aymericzip/intlayer/blob/main/docs/docs/uk/configuration.md).
|
|
143
|
+
|
|
144
|
+
### Крок 3: Інтеграція Intlayer у вашу конфігурацію Angular
|
|
145
|
+
|
|
146
|
+
Щоб інтегрувати Intlayer з Angular CLI, у вас є два варіанти залежно від вашого builder'а: `esbuild` або `webpack`.
|
|
147
|
+
|
|
148
|
+
#### Варіант 1: Використання esbuild (рекомендовано)
|
|
149
|
+
|
|
150
|
+
По-перше, змініть `angular.json`, щоб використовувати кастомний esbuild builder. Оновіть конфігурацію `build`:
|
|
151
|
+
|
|
152
|
+
```json fileName="angular.json"
|
|
153
|
+
{
|
|
154
|
+
"projects": {
|
|
155
|
+
"your-app-name": {
|
|
156
|
+
"architect": {
|
|
157
|
+
"build": {
|
|
158
|
+
"builder": "@angular-builders/custom-esbuild:application",
|
|
159
|
+
"options": {
|
|
160
|
+
"plugins": ["./esbuild/intlayer-plugin.ts"]
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
> Переконайтеся, що ви замінили `your-app-name` на фактичну назву вашого проєкту в `angular.json`.
|
|
170
|
+
|
|
171
|
+
Далі створіть файл `esbuild/intlayer-plugin.ts` у корені вашого проєкту:
|
|
172
|
+
|
|
173
|
+
```typescript fileName="esbuild/intlayer-plugin.ts"
|
|
174
|
+
import { prepareIntlayer, watch } from "@intlayer/chokidar";
|
|
175
|
+
import { getConfiguration, logger } from "@intlayer/config";
|
|
176
|
+
import type { Plugin } from "esbuild";
|
|
177
|
+
|
|
178
|
+
const intlayer: Plugin = {
|
|
179
|
+
name: "intlayer-esbuild-plugin",
|
|
180
|
+
setup(build) {
|
|
181
|
+
const configuration = getConfiguration();
|
|
182
|
+
let isWatching = false;
|
|
183
|
+
|
|
184
|
+
build.onStart(async () => {
|
|
185
|
+
logger("Intlayer esbuild plugin started", {
|
|
186
|
+
level: "info",
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
if (build.initialOptions.watch && !isWatching) {
|
|
190
|
+
logger("Watch mode enabled. Starting watcher...", {
|
|
191
|
+
level: "info",
|
|
192
|
+
});
|
|
193
|
+
watch(configuration);
|
|
194
|
+
isWatching = true;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
try {
|
|
198
|
+
await prepareIntlayer(configuration);
|
|
199
|
+
} catch (error) {
|
|
200
|
+
logger(`Error in Intlayer esbuild plugin: ${error}`, {
|
|
201
|
+
level: "error",
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
export default intlayer;
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
> Пакет `intlayer` для esbuild забезпечує підготовку Intlayer перед початком збірки та відстежує зміни в режимі розробки.
|
|
212
|
+
|
|
213
|
+
#### Варіант 2: Використання Webpack
|
|
214
|
+
|
|
215
|
+
Спочатку змініть `angular.json`, щоб використовувати custom Webpack builder. Оновіть конфігурації `build` та `serve`:
|
|
216
|
+
|
|
217
|
+
```json fileName="angular.json"
|
|
218
|
+
{
|
|
219
|
+
"projects": {
|
|
220
|
+
"your-app-name": {
|
|
221
|
+
"architect": {
|
|
222
|
+
"build": {
|
|
223
|
+
"builder": "@angular-builders/custom-webpack:browser",
|
|
224
|
+
"options": {
|
|
225
|
+
"customWebpackConfig": {
|
|
226
|
+
"path": "./webpack.config.js"
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
"serve": {
|
|
231
|
+
"builder": "@angular-builders/custom-webpack:dev-server"
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
> Переконайтеся, що ви замінили `your-app-name` на фактичну назву вашого проєкту в `angular.json`.
|
|
240
|
+
|
|
241
|
+
Далі створіть файл `webpack.config.js` у корені вашого проєкту:
|
|
242
|
+
|
|
243
|
+
```javascript fileName="webpack.config.js"
|
|
244
|
+
const { IntlayerWebpackPlugin } = require("@intlayer/webpack");
|
|
245
|
+
|
|
246
|
+
module.exports = {
|
|
247
|
+
plugins: [new IntlayerWebpackPlugin()],
|
|
248
|
+
};
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
> Плагін `IntlayerWebpackPlugin` використовується для інтеграції Intlayer з Webpack. Він забезпечує побудову файлів декларацій контенту та їх моніторинг у режимі розробки. Також плагін задає змінні середовища Intlayer у застосунку. Додатково він надає alias-и для оптимізації продуктивності.
|
|
252
|
+
|
|
253
|
+
### Крок 4: Оголосіть ваш контент
|
|
254
|
+
|
|
255
|
+
Створіть і керуйте своїми деклараціями контенту для збереження перекладів:
|
|
256
|
+
|
|
257
|
+
```tsx fileName="src/app/app.content.ts" contentDeclarationFormat="typescript"
|
|
258
|
+
import { t, type Dictionary } from "intlayer";
|
|
259
|
+
|
|
260
|
+
const appContent = {
|
|
261
|
+
key: "app",
|
|
262
|
+
content: {
|
|
263
|
+
title: t({
|
|
264
|
+
uk: "Привіт",
|
|
265
|
+
en: "Hello",
|
|
266
|
+
fr: "Bonjour",
|
|
267
|
+
es: "Hola",
|
|
268
|
+
}),
|
|
269
|
+
congratulations: t({
|
|
270
|
+
uk: "Вітаємо! Ваш додаток працює. 🎉",
|
|
271
|
+
en: "Congratulations! Your app is running. 🎉",
|
|
272
|
+
fr: "Félicitations! Votre application est en cours d'exécution. 🎉",
|
|
273
|
+
es: "¡Felicidades! Tu aplicación está en ejecución. 🎉",
|
|
274
|
+
}),
|
|
275
|
+
exploreDocs: t({
|
|
276
|
+
uk: "Перегляньте документацію",
|
|
277
|
+
en: "Explore the Docs",
|
|
278
|
+
fr: "Explorer les Docs",
|
|
279
|
+
es: "Explorar los Docs",
|
|
280
|
+
}),
|
|
281
|
+
learnWithTutorials: t({
|
|
282
|
+
uk: "Вчіться за допомогою туторіалів",
|
|
283
|
+
en: "Learn with Tutorials",
|
|
284
|
+
>>> (translated) <<<
|
|
285
|
+
uk: "Вчіться за допомогою туторіалів",
|
|
286
|
+
fr: "Apprendre avec les Tutoriels",
|
|
287
|
+
es: "Aprender con los Tutorios",
|
|
288
|
+
}),
|
|
289
|
+
cliDocs: "Документація CLI",
|
|
290
|
+
angularLanguageService: t({
|
|
291
|
+
uk: "Angular Language Service",
|
|
292
|
+
en: "Angular Language Service",
|
|
293
|
+
fr: "Service de Langage Angular",
|
|
294
|
+
es: "Servicio de Lenguaje Angular",
|
|
295
|
+
}),
|
|
296
|
+
angularDevTools: "Angular DevTools",
|
|
297
|
+
github: "Github",
|
|
298
|
+
twitter: "Twitter",
|
|
299
|
+
youtube: "Youtube",
|
|
300
|
+
},
|
|
301
|
+
} satisfies Dictionary;
|
|
302
|
+
|
|
303
|
+
export default appContent;
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
> Ваші декларації контенту можуть бути визначені будь-де у вашому додатку, як тільки вони включені у директорію `contentDir` (за замовчуванням, `./src`). І вони мають відповідати розширенню файлу декларації контенту (за замовчуванням, `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
|
|
307
|
+
|
|
308
|
+
> Для отримання додаткових відомостей зверніться до [документації з декларації контенту](https://github.com/aymericzip/intlayer/blob/main/docs/docs/uk/dictionary/content_file.md).
|
|
309
|
+
|
|
310
|
+
### Крок 5: Використання Intlayer у вашому коді
|
|
311
|
+
|
|
312
|
+
Щоб використовувати можливості інтернаціоналізації Intlayer у всьому вашому Angular-застосунку, потрібно використовувати функцію `useIntlayer` всередині компонента. Ця функція, доступна з пакета `angular-intlayer`, надає доступ до ваших перекладів у вигляді реактивних сигналів.
|
|
313
|
+
|
|
314
|
+
`IntlayerProvider` зареєстрований у корені застосунку, тому вам не потрібно додавати його до providers вашого модуля.
|
|
315
|
+
|
|
316
|
+
Отримайте доступ до словників контенту у класі вашого компонента:
|
|
317
|
+
|
|
318
|
+
```typescript fileName="src/app/hello-world.component.ts"
|
|
319
|
+
import { Component, signal } from "@angular/core";
|
|
320
|
+
import { useIntlayer } from "angular-intlayer";
|
|
321
|
+
|
|
322
|
+
@Component({
|
|
323
|
+
selector: "app-hello-world",
|
|
324
|
+
standalone: true,
|
|
325
|
+
template: `
|
|
326
|
+
<h1>{{ content().title }}</h1>
|
|
327
|
+
|
|
328
|
+
<div class="card">
|
|
329
|
+
<button type="button" (click)="increment()">
|
|
330
|
+
{{ content().count }} {{ count() }}
|
|
331
|
+
</button>
|
|
332
|
+
<p [innerHTML]="content().edit"></p>
|
|
333
|
+
</div>
|
|
334
|
+
|
|
335
|
+
<p class="read-the-docs">{{ content().readTheDocs }}</p>
|
|
336
|
+
`,
|
|
337
|
+
})
|
|
338
|
+
export class HelloWorldComponent {
|
|
339
|
+
content = useIntlayer("helloworld");
|
|
340
|
+
count = signal(0);
|
|
341
|
+
|
|
342
|
+
increment() {
|
|
343
|
+
this.count.update((value) => value + 1);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
Значення контенту Intlayer повертаються як `Signal`, тому ви отримуєте доступ до значень, викликаючи сигнал у вашому шаблоні: `content().title`.
|
|
349
|
+
|
|
350
|
+
### (Необов'язково) Крок 6: Змініть мову вашого контенту
|
|
351
|
+
|
|
352
|
+
Щоб змінити мову вашого контенту, ви можете використовувати функцію `setLocale`, що надається функцією `useLocale`. Це дозволяє встановити локаль додатка та відповідно оновити контент.
|
|
353
|
+
|
|
354
|
+
Створіть компонент для перемикання між мовами:
|
|
355
|
+
|
|
356
|
+
```typescript fileName="src/app/components/locale-switcher.component.ts"
|
|
357
|
+
import { Component } from "@angular/core";
|
|
358
|
+
import { CommonModule } from "@angular/common";
|
|
359
|
+
import { getLocaleName } from "intlayer";
|
|
360
|
+
import { useLocale } from "angular-intlayer";
|
|
361
|
+
import { FormsModule } from "@angular/forms";
|
|
362
|
+
|
|
363
|
+
@Component({
|
|
364
|
+
selector: "app-locale-switcher",
|
|
365
|
+
standalone: true,
|
|
366
|
+
imports: [CommonModule, FormsModule],
|
|
367
|
+
template: `
|
|
368
|
+
<div class="locale-switcher">
|
|
369
|
+
<select [ngModel]="locale()" (ngModelChange)="changeLocale($event)">
|
|
370
|
+
<option *ngFor="let loc of availableLocales" [value]="loc">
|
|
371
|
+
{{ getLocaleName(loc) }}
|
|
372
|
+
</option>
|
|
373
|
+
</select>
|
|
374
|
+
</div>
|
|
375
|
+
`,
|
|
376
|
+
})
|
|
377
|
+
export class LocaleSwitcherComponent {
|
|
378
|
+
localeInfo = useLocale();
|
|
379
|
+
locale = this.localeInfo.locale;
|
|
380
|
+
availableLocales = this.localeInfo.availableLocales;
|
|
381
|
+
|
|
382
|
+
// Зробити getLocaleName доступним у шаблоні
|
|
383
|
+
getLocaleName = getLocaleName;
|
|
384
|
+
|
|
385
|
+
changeLocale(newLocale: string) {
|
|
386
|
+
this.localeInfo.setLocale(newLocale);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
Потім використайте цей компонент у файлі `app.component.ts`:
|
|
392
|
+
|
|
393
|
+
```typescript fileName="src/app/app.component.ts"
|
|
394
|
+
import { Component } from "@angular/core";
|
|
395
|
+
import { HelloWorldComponent } from "./hello-world.component";
|
|
396
|
+
import { LocaleSwitcherComponent } from "./components/locale-switcher.component";
|
|
397
|
+
|
|
398
|
+
@Component({
|
|
399
|
+
selector: "app-root",
|
|
400
|
+
standalone: true,
|
|
401
|
+
imports: [HelloWorldComponent, LocaleSwitcherComponent],
|
|
402
|
+
template: `
|
|
403
|
+
<div>
|
|
404
|
+
<app-locale-switcher />
|
|
405
|
+
<a href="https://vite.dev" target="_blank">
|
|
406
|
+
<img src="/vite.svg" class="logo" alt="Логотип Vite" />
|
|
407
|
+
</a>
|
|
408
|
+
<a href="https://angular.dev/" target="_blank">
|
|
409
|
+
<img
|
|
410
|
+
src="/assets/angular.svg"
|
|
411
|
+
class="logo angular"
|
|
412
|
+
alt="Логотип Angular"
|
|
413
|
+
/>
|
|
414
|
+
</a>
|
|
415
|
+
</div>
|
|
416
|
+
<app-hello-world />
|
|
417
|
+
`,
|
|
418
|
+
})
|
|
419
|
+
export class AppComponent {}
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
### (Необов'язково) Крок 7: Додайте локалізовану маршрутизацію до вашого застосунку
|
|
423
|
+
|
|
424
|
+
Додавання локалізованої маршрутизації в Angular-застосунку передбачає використання Angular Router з префіксами локалі. Це створює унікальні маршрути для кожної мови, що корисно для SEO.
|
|
425
|
+
|
|
426
|
+
Приклад:
|
|
427
|
+
|
|
428
|
+
```plaintext
|
|
429
|
+
- https://example.com/about
|
|
430
|
+
- https://example.com/es/about
|
|
431
|
+
- https://example.com/fr/about
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
Спочатку переконайтесь, що у вас встановлено `@angular/router`.
|
|
435
|
+
|
|
436
|
+
Далі створіть конфігурацію маршрутизатора, яка обробляє маршрути з урахуванням локалі в `app.routes.ts`.
|
|
437
|
+
|
|
438
|
+
```typescript fileName="src/app/app.routes.ts"
|
|
439
|
+
import { Routes } from "@angular/router";
|
|
440
|
+
import { configuration, localeFlatMap } from "intlayer";
|
|
441
|
+
import { HomeComponent } from "./home/home.component";
|
|
442
|
+
import { RootComponent } from "./root/root.component";
|
|
443
|
+
|
|
444
|
+
const { defaultLocale } = configuration.internationalization;
|
|
445
|
+
|
|
446
|
+
export const routes: Routes = [
|
|
447
|
+
localeFlatMap((localizedData) => [
|
|
448
|
+
{
|
|
449
|
+
path: `${localizedData.urlPrefix}`,
|
|
450
|
+
component: RootComponent,
|
|
451
|
+
data: { locale: localizedData.locale },
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
path: `${localizedData.urlPrefix}/home`,
|
|
455
|
+
component: HomeComponent,
|
|
456
|
+
data: { locale: localizedData.locale },
|
|
457
|
+
},
|
|
458
|
+
]),
|
|
459
|
+
{ path: "**", redirectTo: `/${defaultLocale}/home` },
|
|
460
|
+
];
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
Потім потрібно надати роутер у файлі `app.config.ts`.
|
|
464
|
+
|
|
465
|
+
```typescript fileName="src/app/app.config.ts"
|
|
466
|
+
import { ApplicationConfig } from "@angular/core";
|
|
467
|
+
import { provideRouter } from "@angular/router";
|
|
468
|
+
import { routes } from "./app.routes";
|
|
469
|
+
|
|
470
|
+
export const appConfig: ApplicationConfig = {
|
|
471
|
+
providers: [provideRouter(routes)],
|
|
472
|
+
};
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
### (Необов'язково) Крок 8: Зміна URL під час зміни локалі
|
|
476
|
+
|
|
477
|
+
Щоб автоматично оновлювати URL при зміні мови користувачем, можна змінити компонент `LocaleSwitcher`, щоб він використовував Angular Router:
|
|
478
|
+
|
|
479
|
+
```typescript fileName="src/app/components/locale-switcher.component.ts"
|
|
480
|
+
import { Component, inject } from "@angular/core";
|
|
481
|
+
import { CommonModule } from "@angular/common";
|
|
482
|
+
import { Router } from "@angular/router";
|
|
483
|
+
import { getLocaleName, getLocalizedUrl } from "intlayer";
|
|
484
|
+
import { useLocale } from "angular-intlayer";
|
|
485
|
+
import { FormsModule } from "@angular/forms";
|
|
486
|
+
|
|
487
|
+
@Component({
|
|
488
|
+
selector: "app-locale-switcher",
|
|
489
|
+
standalone: true,
|
|
490
|
+
imports: [CommonModule, FormsModule],
|
|
491
|
+
template: `
|
|
492
|
+
<div class="locale-switcher">
|
|
493
|
+
<select [ngModel]="locale()" (ngModelChange)="changeLocale($event)">
|
|
494
|
+
<option *ngFor="let loc of availableLocales" [value]="loc">
|
|
495
|
+
{{ getLocaleName(loc) }}
|
|
496
|
+
</option>
|
|
497
|
+
</select>
|
|
498
|
+
</div>
|
|
499
|
+
`,
|
|
500
|
+
})
|
|
501
|
+
export class LocaleSwitcherComponent {
|
|
502
|
+
private router = inject(Router);
|
|
503
|
+
|
|
504
|
+
localeInfo = useLocale({
|
|
505
|
+
onLocaleChange: (newLocale) => {
|
|
506
|
+
const currentPath = this.router.url;
|
|
507
|
+
const localizedPath = getLocalizedUrl(currentPath, newLocale);
|
|
508
|
+
this.router.navigateByUrl(localizedPath);
|
|
509
|
+
},
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
locale = this.localeInfo.locale;
|
|
513
|
+
availableLocales = this.localeInfo.availableLocales;
|
|
514
|
+
|
|
515
|
+
getLocaleName = getLocaleName;
|
|
516
|
+
|
|
517
|
+
changeLocale(newLocale: string) {
|
|
518
|
+
this.localeInfo.setLocale(newLocale);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
### (Необов'язково) Крок 9: Змінити мову та напрямок тексту в HTML атрибутах
|
|
524
|
+
|
|
525
|
+
Коли ваш застосунок підтримує кілька мов, важливо оновлювати атрибути `lang` та `dir` тега `<html>`, щоб вони відповідали поточній локалі.
|
|
526
|
+
|
|
527
|
+
Ви можете створити сервіс, який робитиме це автоматично.
|
|
528
|
+
|
|
529
|
+
```typescript fileName="src/app/services/i18n-html-attributes.service.ts"
|
|
530
|
+
import { Injectable, effect } from "@angular/core";
|
|
531
|
+
import { useLocale } from "angular-intlayer";
|
|
532
|
+
import { getHTMLTextDir } from "intlayer";
|
|
533
|
+
|
|
534
|
+
@Injectable({
|
|
535
|
+
providedIn: "root",
|
|
536
|
+
})
|
|
537
|
+
export class I18nHtmlAttributesService {
|
|
538
|
+
private localeInfo = useLocale();
|
|
539
|
+
|
|
540
|
+
constructor() {
|
|
541
|
+
effect(() => {
|
|
542
|
+
const newLocale = this.localeInfo.locale();
|
|
543
|
+
if (newLocale) {
|
|
544
|
+
document.documentElement.lang = newLocale;
|
|
545
|
+
document.documentElement.dir = getHTMLTextDir(newLocale);
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
// Цей метод можна викликати в кореневому компоненті програми, щоб гарантувати ініціалізацію сервісу.
|
|
551
|
+
init() {}
|
|
552
|
+
}
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
Потім інжектуйте та ініціалізуйте цей сервіс у вашому головному `AppComponent`:
|
|
556
|
+
|
|
557
|
+
```typescript fileName="src/app/app.component.ts"
|
|
558
|
+
import { Component, inject } from "@angular/core";
|
|
559
|
+
// ... інші імпорти
|
|
560
|
+
import { I18nHtmlAttributesService } from "./services/i18n-html-attributes.service";
|
|
561
|
+
|
|
562
|
+
@Component({
|
|
563
|
+
// ... інші параметри
|
|
564
|
+
})
|
|
565
|
+
export class AppComponent {
|
|
566
|
+
constructor() {
|
|
567
|
+
inject(I18nHtmlAttributesService).init();
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
### (Необов'язково) Крок 10: Створення директиви локалізованого посилання
|
|
573
|
+
|
|
574
|
+
Щоб навігація вашого застосунку враховувала поточну локаль, ви можете створити власну директиву. Ця директива автоматично додає префікс поточної мови до внутрішніх URL.
|
|
575
|
+
|
|
576
|
+
```typescript fileName="src/app/directives/localized-link.directive.ts"
|
|
577
|
+
import { Directive, Input, HostBinding, inject } from "@angular/core";
|
|
578
|
+
import { getLocalizedUrl } from "intlayer";
|
|
579
|
+
import { useLocale } from "angular-intlayer";
|
|
580
|
+
|
|
581
|
+
@Directive({
|
|
582
|
+
selector: "a[appLocalizedLink]",
|
|
583
|
+
standalone: true,
|
|
584
|
+
})
|
|
585
|
+
export class LocalizedLinkDirective {
|
|
586
|
+
@Input("href") originalHref: string = "";
|
|
587
|
+
|
|
588
|
+
private localeInfo = useLocale();
|
|
589
|
+
|
|
590
|
+
@HostBinding("href")
|
|
591
|
+
get localizedHref(): string {
|
|
592
|
+
const locale = this.localeInfo.locale();
|
|
593
|
+
const isExternalLink = /^https?:\/\//.test(this.originalHref);
|
|
594
|
+
|
|
595
|
+
if (isExternalLink || !this.originalHref) {
|
|
596
|
+
return this.originalHref;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
return getLocalizedUrl(this.originalHref, locale);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
Щоб використовувати її, додайте директиву `appLocalizedLink` до ваших тегів <a> і переконайтеся, що імпортували її в компоненті.
|
|
605
|
+
|
|
606
|
+
```typescript fileName="src/app/app.component.ts"
|
|
607
|
+
// ...
|
|
608
|
+
import { LocalizedLinkDirective } from "./directives/localized-link.directive";
|
|
609
|
+
|
|
610
|
+
@Component({
|
|
611
|
+
selector: "app-root",
|
|
612
|
+
standalone: true,
|
|
613
|
+
imports: [/*...,*/ LocalizedLinkDirective],
|
|
614
|
+
template: ` <a href="/home" appLocalizedLink>Головна</a> `,
|
|
615
|
+
})
|
|
616
|
+
export class AppComponent {}
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
### (Необов'язково) Крок 11: Відображення Markdown
|
|
620
|
+
|
|
621
|
+
Intlayer підтримує рендеринг вмісту Markdown. Щоб конвертувати Markdown у багатий HTML, ви можете інтегрувати [markdown-it](https://github.com/markdown-it/markdown-it).
|
|
622
|
+
|
|
623
|
+
Спочатку встановіть `markdown-it`:
|
|
624
|
+
|
|
625
|
+
```bash
|
|
626
|
+
npm install markdown-it
|
|
627
|
+
# і його типи
|
|
628
|
+
npm install -D @types/markdown-it
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
Далі налаштуйте `INTLAYER_MARKDOWN_TOKEN` у вашому `app.config.ts`.
|
|
632
|
+
|
|
633
|
+
```typescript fileName="src/app/app.config.ts"
|
|
634
|
+
import { ApplicationConfig } from "@angular/core";
|
|
635
|
+
import { provideRouter } from "@angular/router";
|
|
636
|
+
import { routes } from "./app.routes";
|
|
637
|
+
import { createIntlayerMarkdownProvider } from "angular-intlayer/markdown";
|
|
638
|
+
import MarkdownIt from "markdown-it";
|
|
639
|
+
|
|
640
|
+
const md = new MarkdownIt({
|
|
641
|
+
html: true,
|
|
642
|
+
linkify: true,
|
|
643
|
+
typographer: true,
|
|
644
|
+
});
|
|
645
|
+
|
|
646
|
+
export const appConfig: ApplicationConfig = {
|
|
647
|
+
providers: [
|
|
648
|
+
provideRouter(routes),
|
|
649
|
+
createIntlayerMarkdownProvider((markdown) => md.render(markdown)),
|
|
650
|
+
],
|
|
651
|
+
};
|
|
652
|
+
```
|
|
653
|
+
|
|
654
|
+
За замовчуванням Intlayer повертає згенерований HTML у вигляді рядка. Якщо ви прив'язуєте його через `[innerHTML]`, будьте уважні до наслідків для безпеки (XSS). Завжди переконуйтеся, що ваш вміст походить з довіреного джерела.
|
|
655
|
+
|
|
656
|
+
Для більш складних сценаріїв ви можете створити pipe, щоб безпечно відрендерити HTML.
|
|
657
|
+
|
|
658
|
+
### Налаштування TypeScript
|
|
659
|
+
|
|
660
|
+
Intlayer використовує module augmentation, щоб скористатися перевагами TypeScript і зробити вашу codebase надійнішою.
|
|
661
|
+
|
|
662
|
+

|
|
663
|
+
|
|
664
|
+

|
|
665
|
+
|
|
666
|
+
Переконайтеся, що ваша конфігурація TypeScript містить автогенеровані типи.
|
|
667
|
+
|
|
668
|
+
```json5 fileName="tsconfig.json"
|
|
669
|
+
{
|
|
670
|
+
// ... Ваші існуючі конфігурації TypeScript
|
|
671
|
+
"include": [
|
|
672
|
+
// ... Ваші існуючі конфігурації TypeScript
|
|
673
|
+
".intlayer/**/*.ts", // Включити автогенеровані типи
|
|
674
|
+
],
|
|
675
|
+
}
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
### Налаштування Git
|
|
679
|
+
|
|
680
|
+
Рекомендується ігнорувати файли, згенеровані Intlayer. Це дозволяє уникнути їх коміту в ваш Git-репозиторій.
|
|
681
|
+
|
|
682
|
+
Для цього ви можете додати наступні інструкції до вашого файлу `.gitignore`:
|
|
683
|
+
|
|
684
|
+
```plaintext
|
|
685
|
+
# Ігнорувати файли, згенеровані Intlayer
|
|
686
|
+
.intlayer
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
### Розширення VS Code
|
|
690
|
+
|
|
691
|
+
Щоб покращити ваш досвід розробки з Intlayer, ви можете встановити офіційне **Intlayer VS Code Extension**.
|
|
692
|
+
|
|
693
|
+
[Встановити з VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
694
|
+
|
|
695
|
+
Це розширення надає:
|
|
696
|
+
|
|
697
|
+
- **Автодоповнення** для ключів перекладу.
|
|
698
|
+
- **Виявлення помилок у реальному часі** для відсутніх перекладів.
|
|
699
|
+
- **Вбудовані попередні перегляди** перекладеного контенту.
|
|
700
|
+
- **Швидкі дії** для швидкого створення та оновлення перекладів.
|
|
701
|
+
|
|
702
|
+
Для детальнішої інформації про використання розширення зверніться до [документації Intlayer VS Code Extension](https://intlayer.org/doc/vs-code-extension).
|
|
703
|
+
|
|
704
|
+
---
|
|
705
|
+
|
|
706
|
+
### Далі
|
|
707
|
+
|
|
708
|
+
Щоб просунутися далі, ви можете реалізувати [візуальний редактор](https://github.com/aymericzip/intlayer/blob/main/docs/docs/uk/intlayer_visual_editor.md) або винести свій контент, використовуючи [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/uk/intlayer_CMS.md).
|
|
709
|
+
|
|
710
|
+
---
|