-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
loctool, ilib-po: Add support to the loctool for saving intermediate files in po format #31
Conversation
ehoogerbeets
commented
Nov 27, 2024
•
edited
Loading
edited
- ilib-po updates
- Added the ability to encode ResourceArray resources in a po file in a reversible way
- Added support for encoding unique keys for resources that are different than the English string
- Added support for datatypes and project names for each resource and as the default for the whole file
- Fixed a bug where you could not have resources with non-json format comments on them. Now it only parses the json format if the comment starts with '{'
- loctool updates
- Added command-line switch --intermediateFormat to switch between xliff or po intermediate files
- Added IntermediateFile class with a factory method getIntermediateFile() that returns either a PO or Xliff intermediate file. The factory method can also determine the intermediate file type from the file name extension (.po or .xliff) of the requested file.
- Use the new intermediate file support to save the extracted files and the new strings files in either format
- Use the new intermediate file support to read in translation files in either format
145560e
to
4d4ab4c
Compare
f0a2ad0
to
36d7c09
Compare
e8ddbab
to
022fa23
Compare
🦋 Changeset detectedLatest commit: b79d491 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
9a7cd29
to
4bfd09f
Compare
packages/ilib-po/tsconfig.build.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the formatting-only change intentional?
packages/ilib-po/src/Parser.ts
Outdated
defaultDataType: string | undefined = this.datatype, | ||
datatype: string | undefined, | ||
defaultProject: string | undefined = this.projectName, | ||
project: string | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove default*
local variables and use the instance-level value directly whenever you intend to fall back to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't do that -- these ones have a purpose that is different than the instance-level values. The default data type and project name can be defined in the headers of the po file and can be different than the ones specified parameters to the POFile constructor. We still need a place to store that. The default data type and project are parsed out of the header of the po file on lines 204-211. If they are not there in the file, they fall back to the values for the instance. Maybe I should call them defaultFileDataType
and defaultFileProject
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I missed that. So basically, the value attached to the produced resource instance fallback should be 1. from unit 2. from file header 3. from parser instance right? In that case, maybe use the word file instead default (rather than both)
var fileFormat = this.settings.intermediateFormat || "xliff"; | ||
var extractedPath = path.join(dir, base + "-extracted." + fileFormat); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extension string should be separate from the format identifier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now, they are exactly the same, so it is a little silly to introduce a mapping right now.
|
||
/** | ||
* The name of the project that the resources belong to | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document the default value
4fca28f
to
d056255
Compare
... where the key is different than the source string
- 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
- it is usually noted in the header. If it is not there, default to English
- both reading and writing with both PO and xliff files
- getIntermediateFile went into its own factory file - the subclasses of IntermediateFile get their own file - IntermediateFile.js is now just a simple abstract class
- controlled by the command-line argument
- 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
- 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
- based on the intermediateFormat settings - pass the data type and project to the generator - all unit tests pass
- add src to the files in the package
- workspace:* dependencies mean that when you create a tgz file for testing, then you have to make a tgz file for a whole tree of as-yet unpublished and unrelated changes in other parts of the monorepo in order to satisfy all the dependencies. This is onerous for a simple little test. The solution is to use dependencies like workspace:^1.11.0 when you know you only need the older 1.11.0 of the other package for testing.
- moved release notes into the changesets - change dependencies into workspace:^
7eee01d
to
b79d491
Compare