Skip to content

Commit

Permalink
loctool, ilib-po: Add support to the loctool for saving intermediate …
Browse files Browse the repository at this point in the history
…files in po format (#31)

* Add utility functions to convert between common and loctool resources
* Added ResourceArray support to ilib-po
* Add support in the generator for proper keys where the key is different than the source string
* Add an intermediate file to save resources as po or xliff

- includes a factory method to create a new intermediate file
- in the po file format generator, if the comments don't have the
  path, use the resource path to create the colon comment
- added @jest/types so that the IDE stops complaining

* Add the ability to glean the target locale from the file contents

- it is usually noted in the header. If it is not there, default
to English

* Add the ability to write out intermediate files as po or xliff
* Added support for datatypes

- each resource can have its own datatype represented as a #d comment
- each file can have a default datatype given in the "Data-Type:" header

* Add support for project names

- each resource can have its own project name represented as a #p comment
- each file can have a default project name given in the "Project:" header

* Add ability to write to po or xliff intermediate files

- based on the intermediateFormat settings
- pass the data type and project to the generator
- all unit tests pass
  • Loading branch information
ehoogerbeets authored Dec 19, 2024
1 parent c80e4e1 commit 0672f4c
Show file tree
Hide file tree
Showing 46 changed files with 3,409 additions and 434 deletions.
16 changes: 16 additions & 0 deletions .changeset/breezy-cows-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
"ilib-po": minor
---

- Added the ability to ilib-po to encode ResourceArray resources. The array elements
are encoded as separate resources with the key of the array resource
and the index of the array element both encoded in new types of comments
in the po file. These are po file format extensions which are mostly
ignored by other po file tools, but are used by the ilib-po parser and
generator to encode the array elements in a reversible way.
- The above work with ResourceArray resources now also allow you to add
a key to each resource that is different than source string. This goes
for all resource types, not just arrays.
- Fixed a bug where resources that have comments in them which are not
in json format were parsed as if they were json. Now the parser will
only treat comments as json if they start with a '{' character.
13 changes: 13 additions & 0 deletions .changeset/ten-students-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
"loctool": minor
---

- Added the ability to read and write intermediate files in po format
- Added a new command-line parameter "--intermediateFormat" to choose
between xliff (default) and po
- The output intermediate files are the `<project>-extracted.<ext>` and
`<project>-new-<locale>.<ext>` files.
- Can represent all of string, plural, or array resources
- Can also read po or xliff files as the source of translations
in the xliffs dir. (Unfortunately, the parameter is still called
xliffsDir even though it may now contain po files with translations.)
107 changes: 0 additions & 107 deletions packages/ilib-po/.gitignore

This file was deleted.

2 changes: 1 addition & 1 deletion packages/ilib-po/docs/assets/search.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0672f4c

Please sign in to comment.