Skip to content

Configuration and Project Defaults

Konstantin Komelin edited this page Mar 6, 2023 · 16 revisions
Config variable Default Meaning
directories app, resources Directories to search in.
excluded-directories No value Directories to exclude from search. These directories should be relative to the ones listed in directories. For example, if you have 'resources' in directories, then to ignore the 'resources/ignored' directory, you need to add 'ignored' to the excluded-directories list.
patterns *.php, *.js File patterns to search for.
allow-newlines false Indicates whether new lines are allowed in translations.
functions __, _t, @lang Translation function names or custom transform function declarations. Example of a custom transform function declaration: 'transform' => fn ($s) => \strtoupper(\str_replace(["-","_"], " ", $s)). If your function name contains $ escape it using \$ .
sort-keys true Indicates whether you need to sort the translations alphabetically by original strings (keys). It helps navigate a translation file and detect possible duplicates.
add-persistent-strings-to-translations false Indicates whether keys from the persistent-strings file should be also added to translation files automatically on export if they don't yet exist there.
exclude-translation-keys false Indicates whether it's necessary to exclude Laravel translation keys from the resulting language file if they have corresponding translations in the given language. This option allows correctly combine two translation approaches: Laravel translation keys (PHP) and translatable strings (JSON).
put-untranslated-strings-at-the-top false Indicates whether you need to put untranslated strings at the top of a translation file. The criterion of whether a string is untranslated is if its key and value are equivalent. If sorting is enabled, untranslated and translated strings are sorted separately.

Change configuration

To change the defaults, you might want to copy the config file into your project config folder and make changes in it:

php artisan vendor:publish --provider="KKomelin\TranslatableStringExporter\Providers\ExporterServiceProvider"
Clone this wiki locally