\n\n\n```\n\n \n \n\nTo use embedded file content in Svelte components, retrieve it via the `useIntlayer` hook. The store is accessed with `$`. Here's an example:\n\n```svelte fileName=\"**/*.svelte\"\n\n\n
\n
{$content.myFile}
\n
\n```\n\n
\n \n\nTo use embedded file content in Preact components, retrieve it via the `useIntlayer` hook. Here's an example:\n\n```tsx fileName=\"**/*.tsx\" codeFormat={[\"typescript\", \"esm\"]}\nimport type { FC } from \"preact\";\nimport { useIntlayer } from \"preact-intlayer\";\n\nconst FileComponent: FC = () => {\n const { myFile } = useIntlayer(\"my_key\");\n\n return (\n
\n
{myFile}
\n
\n );\n};\n\nexport default FileComponent;\n```\n\n
\n \n\nTo use embedded file content in SolidJS components, retrieve it via the `useIntlayer` hook. Here's an example:\n\n```tsx fileName=\"**/*.tsx\" codeFormat={[\"typescript\", \"esm\"]}\nimport type { Component } from \"solid-js\";\nimport { useIntlayer } from \"solid-intlayer\";\n\nconst FileComponent: Component = () => {\n const { myFile } = useIntlayer(\"my_key\");\n\n return (\n
\n
{myFile}
\n
\n );\n};\n\nexport default FileComponent;\n```\n\n
\n \n\nTo use embedded file content in Angular components, retrieve it via the `useIntlayer` hook. Here's an example:\n\n```typescript fileName=\"app.component.ts\" codeFormat=\"typescript\"\nimport { Component } from \"@angular/core\";\nimport { useIntlayer } from \"angular-intlayer\";\n\n@Component({\n selector: \"app-file\",\n template: `\n
\n
{{ content().myFile }}
\n
\n `,\n})\nexport class FileComponent {\n content = useIntlayer(\"my_key\");\n}\n```\n\n
\n \n\nTo use embedded file content with `vanilla-intlayer`, retrieve it via the `useIntlayer` hook. Here's an example:\n\n```typescript fileName=\"**/*.ts\" codeFormat={[\"typescript\", \"esm\"]}\nimport { installIntlayer, useIntlayer } from \"vanilla-intlayer\";\n\ninstallIntlayer();\n\nconst content = useIntlayer(\"my_key\").onChange((newContent) => {\n document.getElementById(\"file-content\")!.textContent = newContent.myFile;\n});\n\n// Initial render\ndocument.getElementById(\"file-content\")!.textContent = content.myFile;\n```\n\n \n\n## Konfiguracja zawartości pliku\n\nAby osadzić zawartość pliku w projekcie Intlayer, użyj funkcji `file` w module zawartości. Poniżej znajdują się przykłady różnych implementacji.\n\n```typescript fileName=\"**/*.content.ts\" contentDeclarationFormat={[\"typescript\", \"esm\", \"commonjs\"]}\nimport { file, type Dictionary } from \"intlayer\";\n\nconst myFileContent = {\n key: \"my_key\",\n content: {\n myFile: file(\"./path/to/file.txt\"),\n },\n} satisfies Dictionary;\n\nexport default myFileContent;\n```\n\n```json5 fileName=\"**/*.content.json\" contentDeclarationFormat=\"json\"\n{\n \"$schema\": \"https://intlayer.org/schema.json\",\n \"key\": \"my_key\",\n \"content\": {\n \"myFile\": {\n \"nodeType\": \"file\",\n \"value\": \"./path/to/file.txt\",\n },\n },\n}\n```\n\n## Używanie zawartości pliku w React Intlayer\n\n\n \n\nTo use embedded file content in a React component, import and use the `useIntlayer` hook from the `react-intlayer` package. This retrieves the content from the specified key and allows it to be displayed dynamically.\n\n```tsx fileName=\"**/*.tsx\" codeFormat={[\"typescript\", \"esm\"]}\nimport type { FC } from \"react\";\nimport { useIntlayer } from \"react-intlayer\";\n\nconst FileComponent: FC = () => {\n const { myFile } = useIntlayer(\"my_key\");\n\n return (\n
\n
{myFile}
\n
\n );\n};\n\nexport default FileComponent;\n```\n\n
\n \n\nTo use embedded file content in Next.js Client Components, retrieve it via the `useIntlayer` hook. Here's an example:\n\n```tsx fileName=\"**/*.tsx\" codeFormat={[\"typescript\", \"esm\"]}\n\"use client\";\n\nimport type { FC } from \"react\";\nimport { useIntlayer } from \"next-intlayer\";\n\nconst FileComponent: FC = () => {\n const { myFile } = useIntlayer(\"my_key\");\n\n return (\n
\n
{myFile}
\n
\n );\n};\n\nexport default FileComponent;\n```\n\n
\n \n\nTo use embedded file content in Vue components, retrieve it via the `useIntlayer` hook. Here's an example:\n\n```vue fileName=\"**/*.vue\"\n\n\n\n```\n\n \n \n\nTo use embedded file content in Svelte components, retrieve it via the `useIntlayer` hook. The store is accessed with `$`. Here's an example:\n\n```svelte fileName=\"**/*.svelte\"\n\n\n
\n
{$content.myFile}
\n
\n```\n\n
\n \n\nTo use embedded file content in Preact components, retrieve it via the `useIntlayer` hook. Here's an example:\n\n```tsx fileName=\"**/*.tsx\" codeFormat={[\"typescript\", \"esm\"]}\nimport type { FC } from \"preact\";\nimport { useIntlayer } from \"preact-intlayer\";\n\nconst FileComponent: FC = () => {\n const { myFile } = useIntlayer(\"my_key\");\n\n return (\n
\n
{myFile}
\n
\n );\n};\n\nexport default FileComponent;\n```\n\n
\n \n\nTo use embedded file content in SolidJS components, retrieve it via the `useIntlayer` hook. Here's an example:\n\n```tsx fileName=\"**/*.tsx\" codeFormat={[\"typescript\", \"esm\"]}\nimport type { Component } from \"solid-js\";\nimport { useIntlayer } from \"solid-intlayer\";\n\nconst FileComponent: Component = () => {\n const { myFile } = useIntlayer(\"my_key\");\n\n return (\n
\n
{myFile}
\n
\n );\n};\n\nexport default FileComponent;\n```\n\n
\n \n\nTo use embedded file content in Angular components, retrieve it via the `useIntlayer` hook. Here's an example:\n\n```typescript fileName=\"app.component.ts\" codeFormat=\"typescript\"\nimport { Component } from \"@angular/core\";\nimport { useIntlayer } from \"angular-intlayer\";\n\n@Component({\n selector: \"app-file\",\n template: `\n
\n
{{ content().myFile }}
\n
\n `,\n})\nexport class FileComponent {\n content = useIntlayer(\"my_key\");\n}\n```\n\n
\n \n\nTo use embedded file content with `vanilla-intlayer`, retrieve it via the `useIntlayer` hook. Here's an example:\n\n```typescript fileName=\"**/*.ts\" codeFormat={[\"typescript\", \"esm\"]}\nimport { installIntlayer, useIntlayer } from \"vanilla-intlayer\";\n\ninstallIntlayer();\n\nconst content = useIntlayer(\"my_key\").onChange((newContent) => {\n document.getElementById(\"file-content\")!.textContent = newContent.myFile;\n});\n\n// Initial render\ndocument.getElementById(\"file-content\")!.textContent = content.myFile;\n```\n\n \n
\n\n## Przykład wielojęzycznego Markdown\n\nAby obsługiwać wielojęzyczne edytowalne pliki Markdown, możesz użyć `file` w połączeniu z `t()` i `md()`, aby zdefiniować różne wersje językowe pliku z zawartością Markdown.\n\n```typescript fileName=\"**/*.content.ts\" contentDeclarationFormat={[\"typescript\", \"esm\", \"commonjs\"]}\nimport { file, t, md, type Dictionary } from \"intlayer\";\n\nconst myMultilingualContent = {\n key: \"my_multilingual_key\",\n content: {\n myContent: md(\n t({\n en: file(\"src/components/test.en.md\"),\n fr: file(\"src/components/test.fr.md\"),\n es: file(\"src/components/test.es.md\"),\n })\n ),\n },\n} satisfies Dictionary;\n\nexport default myMultilingualContent;\n```\n\nTa konfiguracja pozwala na dynamiczne pobieranie zawartości w oparciu o preferencje językowe użytkownika. Gdy jest używana w Intlayer Visual Editor lub CMS, system rozpozna, że zawartość pochodzi z określonych plików Markdown i zapewni, że pozostaną one edytowalne.\n\n## Różne typy ścieżek\n\nPodczas używania funkcji `file` można stosować różne typy ścieżek do określenia pliku do osadzenia.\n\n- `file(\"./path/to/file.txt\")` - Ścieżka względna względem bieżącego pliku\n- `file(\"path/to/file.txt\")` - Ścieżka względna względem katalogu głównego projektu\n- `file(\"/users/username/path/to/file.txt\")` - Ścieżka absolutna\n\n## Jak Intlayer obsługuje zawartość plików\n\nFunkcja `file` opiera się na module `fs` Node.js, aby odczytać zawartość określonego pliku i wstawić ją do słownika. Używana w połączeniu z Intlayer Visual Editor lub CMS, Intlayer może śledzić relację między słownikiem a plikiem. Pozwala to Intlayer na:\n\n- Rozpoznanie, że zawartość pochodzi z określonego pliku.\n- Automatyczną aktualizację zawartości słownika, gdy powiązany plik zostanie edytowany.\n- Zapewnić synchronizację między plikiem a słownikiem, zachowując integralność zawartości.\n\n## Dodatkowe zasoby\n\nAby uzyskać więcej informacji na temat konfigurowania i używania osadzania plików w Intlayer, zapoznaj się z następującymi zasobami:\n\n- [Dokumentacja Intlayer CLI](/pl/doc/concept/cli)\n- [Dokumentacja React Intlayer](/pl/doc/environment/create-react-app)\n- [Dokumentacja Next Intlayer](/pl/doc/environment/nextjs/15)\n- [Dokumentacja zawartości Markdown](/pl/doc/concept/content/markdown)\n- [Dokumentacja zawartości tłumaczeń](/pl/doc/concept/content/translation)\n\nTe zasoby dostarczają dodatkowych informacji na temat osadzania plików, zarządzania zawartością oraz integracji Intlayer z różnymi frameworkami.\n","description":"Dowiedz się, jak osadzić zewnętrzne pliki w słowniku treści za pomocą funkcji `file`. Ta dokumentacja wyjaśnia, jak Intlayer dynamicznie łączy i zarządza zawartością plików.","url":"https://intlayer.org/pl/doc/concept/content/file","datePublished":"2025-03-13","dateModified":"2025-06-29","version":"5.5.10","keywords":"Plik, Internacjonalizacja, Dokumentacja, Intlayer, Next.js, JavaScript, React","license":"https://raw.githubusercontent.com/aymericzip/intlayer/refs/heads/main/LICENSE","audience":{"@type":"Audience","audienceType":"Programiści, Menedżerowie treści"}}
    Autor:
    Data utworzenia:2025-03-13Ostatnia aktualizacja:2025-06-29

    Zawartość pliku / Osadzanie plików w Intlayer

    W Intlayer funkcja file pozwala na osadzenie zawartości zewnętrznego pliku w słowniku. Takie podejście zapewnia, że Intlayer rozpoznaje plik źródłowy, umożliwiając płynną integrację z Intlayer Visual Editor i CMS.

    Dlaczego używać file zamiast import, require lub fs?

    To use embedded file content in a React component, import and use the useIntlayer hook from the react-intlayer package. This retrieves the content from the specified key and allows it to be displayed dynamically.

    **/*.tsx
    import type { FC } from "react";
    import { useIntlayer } from "react-intlayer";
    
    const FileComponent: FC = () => {
    const { myFile } = useIntlayer("my_key");
    
    return (
      <div>
        <pre>{myFile}</pre>
      </div>
    );
    };
    
    export default FileComponent;

    Konfiguracja zawartości pliku

    Aby osadzić zawartość pliku w projekcie Intlayer, użyj funkcji file w module zawartości. Poniżej znajdują się przykłady różnych implementacji.

    **/*.content.ts
    import { file, type Dictionary } from "intlayer";
    
    const myFileContent = {
      key: "my_key",
      content: {
        myFile: file("./path/to/file.txt"),
      },
    } satisfies Dictionary;
    
    export default myFileContent;

    Używanie zawartości pliku w React Intlayer

    To use embedded file content in a React component, import and use the useIntlayer hook from the react-intlayer package. This retrieves the content from the specified key and allows it to be displayed dynamically.

    **/*.tsx
    import type { FC } from "react";
    import { useIntlayer } from "react-intlayer";
    
    const FileComponent: FC = () => {
    const { myFile } = useIntlayer("my_key");
    
    return (
      <div>
        <pre>{myFile}</pre>
      </div>
    );
    };
    
    export default FileComponent;

    Przykład wielojęzycznego Markdown

    Aby obsługiwać wielojęzyczne edytowalne pliki Markdown, możesz użyć file w połączeniu z t() i md(), aby zdefiniować różne wersje językowe pliku z zawartością Markdown.

    **/*.content.ts
    import { file, t, md, type Dictionary } from "intlayer";
    
    const myMultilingualContent = {
      key: "my_multilingual_key",
      content: {
        myContent: md(
          t({
            en: file("src/components/test.en.md"),
            fr: file("src/components/test.fr.md"),
            es: file("src/components/test.es.md"),
          })
        ),
      },
    } satisfies Dictionary;
    
    export default myMultilingualContent;

    Ta konfiguracja pozwala na dynamiczne pobieranie zawartości w oparciu o preferencje językowe użytkownika. Gdy jest używana w Intlayer Visual Editor lub CMS, system rozpozna, że zawartość pochodzi z określonych plików Markdown i zapewni, że pozostaną one edytowalne.

    Różne typy ścieżek

    Podczas używania funkcji file można stosować różne typy ścieżek do określenia pliku do osadzenia.

    • file("./path/to/file.txt") - Ścieżka względna względem bieżącego pliku
    • file("path/to/file.txt") - Ścieżka względna względem katalogu głównego projektu
    • file("/users/username/path/to/file.txt") - Ścieżka absolutna

    Jak Intlayer obsługuje zawartość plików

    Funkcja file opiera się na module fs Node.js, aby odczytać zawartość określonego pliku i wstawić ją do słownika. Używana w połączeniu z Intlayer Visual Editor lub CMS, Intlayer może śledzić relację między słownikiem a plikiem. Pozwala to Intlayer na:

    • Rozpoznanie, że zawartość pochodzi z określonego pliku.
    • Automatyczną aktualizację zawartości słownika, gdy powiązany plik zostanie edytowany.
    • Zapewnić synchronizację między plikiem a słownikiem, zachowując integralność zawartości.

    Dodatkowe zasoby

    Aby uzyskać więcej informacji na temat konfigurowania i używania osadzania plików w Intlayer, zapoznaj się z następującymi zasobami:

    Te zasoby dostarczają dodatkowych informacji na temat osadzania plików, zarządzania zawartością oraz integracji Intlayer z różnymi frameworkami.