-
Notifications
You must be signed in to change notification settings - Fork 5
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
Allow numbers and symbols on yaml context #309
Allow numbers and symbols on yaml context #309
Conversation
1dabb16
to
590e19c
Compare
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.
Let's add a test case with !!
as well
ignore my comment, I see that we already have such tests in place |
c8ea0bf
to
01753fe
Compare
0de4746
to
1c8c021
Compare
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.
Looks great! The comment is optional.
Built-in types, indicated by a `!!` prefix, will not be matched. We | ||
can't preserve the information whether a built-in tag like `!!str` was | ||
used for a value since the PyYAML library will tag such entries with | ||
the built-in identifier. For example `tag:yaml.org,2002:str`, not | ||
`!!str`. | ||
""" | ||
return re.match(ensure_unicode(r'^[\![a-zA-Z_]*]*$'), | ||
|
||
return re.match(ensure_unicode(r'^\![a-zA-Z0-9_:.\-]*$'), |
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.
Why not \w
instead of a-zA-Z0-9
?
openformats/formats/yaml/utils.py
Outdated
tag, | ||
re.IGNORECASE) | ||
|
||
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.
The linter is not going to like this.
1c8c021
to
eea8c3e
Compare
eea8c3e
to
6b0bdd4
Compare
6b0bdd4
to
b1c8d33
Compare
Problem and/or solution
So far, we've been able to include context in YAML files (YAML_GENERIC, YML i18n) tx doc by utilizing custom YAML tags .
For instance:
However, our Yaml parser for the context only allows alphabetic characters, zeros, and underscores. For instance:
We have now extended support to include numbers and a limited set of special symbols namely (- _ : .).
Additionally, the context is stored in our database with the exclamation mark, and we aim to remove it.
backwards compatibility
slack conversation about it: https://transifex.slack.com/archives/C01BHGRAGH1/p1693309705338759
How to test
Upload a YML i18n and a YAML_GENERIC resource file that includes custom tags featuring numbers or special symbols.
We expect these contextes:
We expect a downloaded file for the source language like this:
We expect for the translation language a file like this:
Staging: https://yamlcntxt.stg.transifex.net/
Reviewer checklist
Code:
PR: