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

Uppercase keys support #9

Closed
Christophe668 opened this issue Jan 20, 2015 · 17 comments
Closed

Uppercase keys support #9

Christophe668 opened this issue Jan 20, 2015 · 17 comments

Comments

@Christophe668
Copy link

Hi,

I'm getting a crash when using Phrase.from("This is an {EXAMPLE}");
Throwing a 'Unexpected character 'E'; expected key.'

Could you add support for uppercase keys? It would help me since i'm not controlling the strings I receive.

Thank you !

@quinnjn
Copy link
Contributor

quinnjn commented Jan 28, 2015

I'd like to expand this request further. Is there a reason why phrase doesn't allow uppercase characters, symbols, or numbers?

@dlew
Copy link
Contributor

dlew commented Feb 18, 2015

It seems like it ought to accept any value that is valid as an Android resource.

I'm willing to do a PR on this but I'm curious if there is a reason it was purposefully avoided before I jump in.

@quinnjn
Copy link
Contributor

quinnjn commented Feb 18, 2015

@dlew ditto. I have something in the works but I've been waiting for input on this issue. Their exists a test case stating no uppercase characters so I'd like some feedback on why.

@Querschlag
Copy link

If that's an expected behaviour I suggest to include this in the documentation. I struggled quiet a while to track down the cause of error java.lang.IllegalArgumentException: Missing closing brace: } ...

@loganj
Copy link
Collaborator

loganj commented Feb 4, 2016

We don't support uppercase characters because we haven't seen a need. If anything we could ignore case, but why?

Closing, feel free to reopen if you're still interested and care to make the case.

Sorry for the pun.

@loganj loganj closed this as completed Feb 4, 2016
@loganj loganj mentioned this issue Feb 4, 2016
@rocboronat
Copy link

This issue is a key one. Is what Phrase newcomers expects Phrase to do. Please, reopen it and accept #17. Thanks!

@ryust
Copy link

ryust commented Jul 19, 2017

Just because you don't see a need doesn't mean there isn't one. I have a use case of migrating from a different substitution library that used uppercase for their keys and I can't have all my users manually translating their uppercase parameters to lowercase. I've made the case.

The bigger question is instead of "why", is "why not"?

@JakeWharton
Copy link
Member

Nope. For libraries the question is always "why".

@pforhan
Copy link
Contributor

pforhan commented Jul 19, 2017

I think there's a very good case for fixing the terrible error message. When that's done I think this will matter less to folks as they'll get immediate feedback on the problem, and won't have to dig.

I'll see if I can put a pull request together, I just ran into this last week.

@pforhan
Copy link
Contributor

pforhan commented Jul 19, 2017

Oh, #33 almost does this, test is a little weak though.

@ryust
Copy link

ryust commented Jul 19, 2017

Ok, then I'll rephrase my question, "why lowercase"? Someone made a binary decision... could have been uppercase.

@JakeWharton
Copy link
Member

JakeWharton commented Jul 19, 2017 via email

@ryust
Copy link

ryust commented Jul 19, 2017

The Android standard for constants seems to be uppercase in most of the projects I've seen. Parameterized strings with uppercase keys would also be much easier to identify... so in another time and place the uppercase decision could have as easily been justified by someone else.

Not trying to give you a hard time, and actually I don't care as I've moved on to different software, but the polarized right/wrong views just irk me.

@JakeWharton
Copy link
Member

JakeWharton commented Jul 19, 2017 via email

@dlew
Copy link
Contributor

dlew commented Jul 20, 2017

actually I don't care as I've moved on to different software

If it doesn't matter to you, then maybe you shouldn't be taking up other peoples' time and effort with the matter? Maintaining a library is a chore, there's no need to make it harder than it already is.

@rocboronat
Copy link

rocboronat commented Jul 20, 2017

At least, improve the error message Unexpected character 'E'; expected key.

What about Unexpected character 'E'. Phrase keys must be lowercase.?

@pforhan
Copy link
Contributor

pforhan commented Jul 21, 2017

See #35 for a fix to the error messages for invalid key names.

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

No branches or pull requests

9 participants