Skip to content

Commit

Permalink
Merge pull request #1225 from pkp/dev-locale-tools
Browse files Browse the repository at this point in the history
Improve dev docs for locale key tools
  • Loading branch information
asmecher authored Jul 15, 2024
2 parents d67e974 + 2fdab76 commit 7af882e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
18 changes: 15 additions & 3 deletions dev/documentation/3.3/en/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,24 @@ Dates should be in the format `YYYY-MM-DD`.

## Remove a locale key

A CLI tool is available to remove locale keys. This can be useful when a locale key is no longer used and needs to be removed from every locale.
A CLI tool to remove locale keys. This can be useful when a locale key is no longer used and needs to be removed from every locale.

From the rood directory of an application, run:
From the root directory of an application, run:

```
php tools/removeLocaleKey.php example.locale.key
```

It will remove all instances of that locale key from every locale `.po` file in the application and pkp-lib.
It will remove all instances of that locale key from every locale `.po` file in the application and pkp-lib.

## Move a locale key to pkp-lib

A CLI tool to move a locale key from one file to another and apply the change across all languages. Use this to move a locale key from an application directory to pkp-lib. Use the `-r` flag to move a key from pkp-lib to the application.

Run the following from the root directory of an application.

```
php lib/pkp/tools/moveLocaleKeysToLib.php example.locale.key emails.po
```

This will move all translations of `example.locale.key` from `locale/**_**/emails.po` to `lib/pkp/locale/**_**/emails.po`.
4 changes: 4 additions & 0 deletions dev/documentation/3.3/en/utilities-translation.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,7 @@ Supported submission locales include languages for which the journal, press or p
```php
$locales = $context->getSupportedSubmissionLocales();
```

## Locale File Tools

Tools are available to perform bulk operations on locale files. See [Resources](./resources) to learn more about these tools and how to use them.
16 changes: 14 additions & 2 deletions dev/documentation/en/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Dates should be in the format `YYYY-MM-DD`.

## Remove a locale key

A CLI tool is available to remove locale keys. This can be useful when a locale key is no longer used and needs to be removed from every locale.
A CLI tool to remove locale keys. This can be useful when a locale key is no longer used and needs to be removed from every locale.

Run the following from the root directory of an application.

Expand All @@ -56,7 +56,7 @@ It will remove all instances of that locale key from every locale `.po` file in

## Move a locale key to pkp-lib

A CLI tool to move a locale key from one file to another and apply the change across all languages. Use this to move a locale key from an application directory to pkp-lib.
A CLI tool to move a locale key from one file to another and apply the change across all languages. Use this to move a locale key from an application directory to pkp-lib. Use the `-r` flag to move a key from pkp-lib to the application.

Run the following from the root directory of an application.

Expand All @@ -66,6 +66,18 @@ php lib/pkp/tools/moveLocaleKeysToLib.php example.locale.key emails.po

This will move all translations of `example.locale.key` from `locale/**_**/emails.po` to `lib/pkp/locale/**_**/emails.po`.

### Replace a variable in a locale key

A CLI tool to replace a variable in a locale key across all languages.

Run the following from the root directory of an application.

```
php lib/pkp/tools/replaceVariableInLocaleKey.php example.locale.key oldVariable newVariable
```

It will replace the variable name in all instances of that locale key from every locale `.po` file in the application and pkp-lib.

## Log emails

Sometimes you need to verify if an email was sent by the application. You can output all emails to the server log by setting the following in your config file:
Expand Down
4 changes: 4 additions & 0 deletions dev/documentation/en/utilities-translation.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,7 @@ $currencies = Locale::getCurrencies();
$languages = Locale::getLanguages();
$scripts = Locale::getScripts();
```

## Locale File Tools

Tools are available to perform bulk operations on locale files. See [Resources](./resources) to learn more about these tools and how to use them.

0 comments on commit 7af882e

Please sign in to comment.