-
Notifications
You must be signed in to change notification settings - Fork 156
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
Default nugget has potential clashes with json #69
Comments
If going for [||[message]||], any particular reason why not [|[message]|] ? I haven't used JSON much myself and would just be interested to see a JSON structure that has [[[ or ]]] if you have one to hand. From: Raul Vejar [mailto:notifications@github.com] The default nuggets "[[[" and "]]]" are a somewhat common combination when building a json structure that has arrays within arrays. I've opened this issue so we can track suggestions as well I've been experimenting with '[||[' and ']||]', the seem to work pretty well as '||' is generally used as an or operator that is binary which will make it fail because of the brackets so it is very unlikely we'll run into a case where this has a valid meaning in one of the targeted domains. — |
You asked for it. This is a service response that returns a geo shape for pennsylvania (I'm trimming the middle otherwise it's too big for github). Notice the coordinates array {"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[-80.293756,39.721187],[-80.290936,39.721172],[-80.290809,39.721171],[-80.288876,39.721161],[-80.287441,39.721153],[-80.283903,39.721135],[-80.283508,39.721133],[-80.281164,39.721119], |
Hmm. Boiling that down I'm getting a structure like this:
which can be further simplified to this:
Seems slightly odd structure that but I suppose perfectly valid? There is probably an issue with C-based languages as well with respect to the ending marker:
although I don't think that would be an issue with the present regex used to scan for nuggets as it is making 'ungreedy' matches going from [[[ forwards. |
Because I had to take out a lot of the text to make it fit you can't tell, but the structure is an array of arrays of arrays of coordinates, there is really no way to simplify it if you would see the full content as it is something like |
Even though it is hard to type in on most keyboards and without a keyboard macro, I still like «««message»»». |
Yeah, not being in most keyboards is a major drawback. I can feel the hate mail/github-issues flowing already |
No doubt, but at the same time (playing devils advocate) we're only talking about a default and the haters are free to override. I've got a VS-extension that enters the chevrons on pressing a keyboard shortcut, which could also be wired up to a button next to the PostBuild button. So: [[[message]]] is easy to enter and looks neat, but will always clash with something. |
Haters are free to override, but the default should work fine and easy out of the box for the majority of people Regarding the 'neat looking' factor... I don't know Martin, I guess it doesn't have a lot of value to me, specially compared with 'easiness to enter'. I can hear the screams of my designers already if I tell them they'll have to encode every single visible string of html with characters that are not on the keyboard... The plugin idea... not enough I think. I do feel eventually we'll have to add a plugin that gives warnings on strings that have not been internationalized and potentially suggest applying the nuggets automatically, but a button is not a good solution. The shortcut might be a good idea regardless, but VS has it's own way to defining shortcuts and I've seen plugins (cough RESHARPER) that try to define new ones only to have them clash and make the user go through a conflict resultion process every time the shortcut is used which sucks. |
Okay, I tend to agree on that. In the hope of eliciting more views:
... |
So a general question is how this plays with user entered text. If I render a user generated field they could potentially match by chance any string that we pick. A reasonable assumption is user generated content will be escaped. Is there any reason to avoid something like "<<<" and ">>>" or "<<|" and "|>>"? That way it wouldn't be content that would be expected to be found in a html document. |
Yes, I see your insight there. But I can think of at least one problem which is entering nuggets into an HTML editor, specifically in my case the Visual Studio razor/cshtml editor. E.g.
Another one might be that nuggets could break the HTML if/when they happen to slip through un-parsed, e.g. when testing. My original reason for going with the [ and ] chars was to mimic the XML CDATA element in a way. But you are correct that it will potentially clash with user generated input. Can we say, however, that < and > and the only chars we can assume will be escaped? I presume so as & and apostophe's don't seem to strictly require escaping. I think in recognition of the user-input clash we have had in mind a sequence that is very unlikely to clash. The downside of a clash is only manifest if the whole sequence matches a message for which there is a translation. If there is no translation, then the nugget is left in the output untouched and so no problem. |
May I add to the previous list:
The thinking here is that the ` char (top-left of most keyboards by the looks of it) is easy to type, not requiring SHIFT. In that was it is preferable to | which does require SHIFT on some keyboards, such a UK ones. And also preferable to # which requires shift on a US keyboard (but not UK ...). |
LOL, that idea just tripped over markdown. I thought markdown used three of those ` chars?! Second attempt:
|
@rubydagr I see that <<|message|>> in fact works okay with the VS2012 editor so scrub that objection in that instance. |
Just to come back, we've deployed in production with . It doesn't match any text users could possibly enter, the mark-up remains valid during development, and as a bonus, strings to be translated are color coded. |
That's very helpful, thank you. And I'm pleased to hear the library is working for you. |
Instead of searching for an universal nugget syntax, why not just ad the possibility to override nugget tokens per content type ? |
The default nuggets "[[[" and "]]]" are a somewhat common combination when building a json structure that has arrays within arrays.
Since most people will not change the default, we should try to make sure we pick one that is failry unique among the domains we are targeting (C#, Razor, HTML, Json, Css, XML and all other web-related techs for .net based websites)
I've opened this issue so we can track suggestions as well
I've been experimenting with '[||[' and ']||]', and they seem to work pretty well as '||' is generally used as an or operator that is binary which will make it fail because of the brackets so it is very unlikely we'll run into a case where this has a valid meaning in one of the targeted domains.
The text was updated successfully, but these errors were encountered: