Skip to content
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

Revisit invalid character reporting in validate-strings-file #226

Open
scelis opened this issue Nov 26, 2017 · 3 comments
Open

Revisit invalid character reporting in validate-strings-file #226

scelis opened this issue Nov 26, 2017 · 3 comments

Comments

@scelis
Copy link
Owner

scelis commented Nov 26, 2017

From this comment by @robnadin:

Sorry to comment on up such an old commit, but I'm just wondering why this was changed? As far as I know, aapt automatically converts string names containing dots into underscores, so for example the following key:
network.error

will be converted to:
R.string.network_error

Our workflow would like to take advantage of using dot syntax so we can generate structured keys for iOS using SwiftGen but keeping the validation of the twine .txt file intact. Currently, running Twine with validation checks spits out numerous Found key(s) with invalid characters: warnings etc.

One consideration we need to maintain is how this affects all formatters, not just Android's.

I would like to propose that we:

  1. Get a list of valid / invalid characters for all formatters.
  2. Update validate-strings-file for a common set of characters.
  3. Update validate-strings-file to support the --format option to validate the strings file for a particular format. Thus, if --android is passed in, the Android formatter can provide a list of valid or invalid characters for string keys.

I would love to be able to add support for invalid characters by doing our own replacements (like replace < with _ when we generate the localization file for a format that does not support <). However, this adds many complications with consume-localization-file which may not be worth the complexity and effort.

@sebastianludwig
Copy link
Collaborator

sebastianludwig commented Dec 12, 2017

  • Collect valid key characters for formatters
    • Android
      • Didn't find an answer in the official Android docs. Apparently the same rules as for Java variables
      • [A-Za-z0-9_$] with the addition of . (which will be converted to _ in Java land), but 0-9 aren't allowed as first characters.
    • Apple
    • Django
    • Flash
    • Gettext
    • jQuery
    • Tizen
  • Update validate-strings-file to only allow characters that are valid for all formatters
  • Honor --format option in validate_twine_file

@sebastianludwig
Copy link
Collaborator

Finding out the allowed characters is surprisingly painful. Took me an hour to get some information for the two major platforms. Since nobody has complained for the other formatters, how about we use the current character set for the rest (except for Tizen which is identical to Android I guess), @scelis?

@scelis
Copy link
Owner Author

scelis commented Dec 30, 2017

@sebastianludwig That sounds good to me! Thanks for looking into Android & iOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants