Skip to content

i18n: Add a folder structure option where locale is the root #4416

@chriskirknielsen

Description

@chriskirknielsen

Currently, internationalisation options allow us to store localised files in three structures:

  • multiple_folders - persists files in <folder>/<locale>/<slug>.<extension>
  • multiple_files - persists files in <folder>/<slug>.<locale>.<extension>
  • single_file - persists a single file in <folder>/<slug>.<extension>

Would there be an interest in adding an option such as locale_folders to specify the following structure: <locale>/<folder>/<slug>.<extension>?

For context, I am working with 11ty, and having /en and /fr folders for all of my localised content makes more sense with my configuration than having /pages and /posts folders that contain a folder for each locale. With locales as top-level folders, they can directly pass data down (e.g. /en/en.json data is available in for any file in my /en/pages/* folder, and I can adjust everything for one language in a single folder), which isn't possible with the multiple_folders structure, as far as I know.

I cloned this repo locally and did a quick test, editing the i18n.ts file with the added support I am aiming for — this edit, adding locale_folders into structure options, seems to provide the solution I am looking for, but I am not savvy enough to create all the tests required to form a clean PR for this, though the edits I made are minimal and seem to cover the bases.

Please let me know if I should provide additional details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: i18ntype: featurecode contributing to the implementation of a feature and/or user facing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions