Where to define context data object for L20n? - l20n

I need to provide some context to the localization files. I've read I can provide a context data object (http://l20n.org/learn/using-external-variables-in-translations/), but I have no idea where to store it. Is it attached to the DOM ? Provided with the l20n api?

The solution is to provide it as another data attribute, alongside data-l10n-id.
<div data-l10n-id='promotion_after_amount_text' data-l10n-args='{"amount":"1.5"}'></div>

Related

Adaptive Card: What is the best way to display an arbitrary JSON object?

I'd like to generate an adaptive card that contains an arbitrary JSON
object inside.
I anticipate that the JSON object will be shallow.
Maybe it will contain just a list of key-value pairs.
But I won't know the structure of that JSON object until runtime.
For this reason, I can't templatize this portion of the adaptive card.
It would be ideal if I could embed the JSON inside of a codeblock, but I don't know if that's supported.
Alternatively, I'd be willing to embed the JSON inside of a monotype textbox.
Any help would be greatly appreciated.
Embedding JSON inside of a codeblock isn't yet supported, although that would indeed be a great way to solve this use case.
A template isn't necessarily static or fixed. If you're planning to "expand" your template with the AdaptiveCards.Templating NuGet package for instance, you'll have the occasion to load the template into memory. At this time, you can mutate the template according to the incoming JSON at runtime. This isn't an ideal solution, but it is a way to accommodate a truly arbitrary JSON object.
If, on the other hand, if you anticipate that the JSON object will merely be a list of key-value pairs, you can use data binding.

Google Polymer: Where is the localstorage?

When we use core-localstorage
<core-localstorage name="my-app-storage" value="{{value}}"></core-localstorage>
where it actually store the data? In some file on the HDD? What is the path?
LocalStorage is one of some ways you can store data in the client end in the Hard-drive, different browsers use different locations to save this file.
LocalStraoge makes use of JSON to store information worth up to 10MB(Might differ from browsers).
Usually, storing and retrieving from Local-storage is done through JavaScript but Polymer team has made a custom element you can use to make this process more Declarative.
Using the core-localstorage element:
<core-localstorage name="HOW YOU ACCESS THIS DATA" value="{{THE ACTUAL DATA YOU WANT TO STORE}}"></core-localstorage>
name attribute is how you access this data, every peice of data you store has to have a name with which you can set or get it's value through.
value attribute is the actual data you want to store, it can be an array, object, number or a string.
More documentations about core-localstorage and localstorage can be found at:
https://www.polymer-project.org/0.5/docs/elements/core-localstorage.html
http://diveintohtml5.info/storage.html

Google Realtime API - How to view existing collaboration model?

How do I view existing realtime collaboration data model? I call getRoot method:
var collaborative_model = rtpg.realtimeDoc.getModel().getRoot()
When I vew collaborative_model object in debug, I see cryptic properties only. Not sure if or how my model is saved.
Can I do some kind of variable dump of the model?
You can use https://gist.github.com/cowsrule/6348393 as a mostly plug-and-play dumper for the realtime API collaborative objects. As this relies on internals of the realtime API it will need to be updated (read: break) the next time they update the API.
To use, include on your webpage and set window.remoteDoc to be your realtime document.
To call, pass in the ID of the CollaborativeObject you are interested in inspecting.
The root is just a CollaborativeMap, so you can use the standard map methods to explore its values.
The relevant methods there for digging into the model are keys() and values().
A lot of these data model classes have obfuscated methods that are a part of the internal implementation. The best way to see what methods are publicly available is to look at the API reference.

Single serialization layer to Json with Casbah/Salat

I am trying to create a serialization layer which allows me to:
Store my classes in a MongoDB data source
Convert them to JSON to use them in a REST API.
Some classes are clearly not case classes (because they are inherited from a Java codebase) and I would have to write ad-hoc code for that. Is registering a BSON Hook for my non standard type the correct approach, and does it provide Json serialization?
Salat maintainer here.
You might prefer to create a Salat custom transformer instead of registering a BSON hook with Casbah.
See simple example and spec.
If you run into any issues, feel free to ping the mailing list with a small sample Github project that demonstrates what isn't working.

Best practices to produce JSON from NotesViews or DocumentCollections

I'm working on a custom control that will be fed by JSON content and I'm trying to find the best approach to produce and consume it.
Let say the JSON could be from:
Notes View (all documents)
Notes View (subset of documents based on a category or filter)
Notes Document Collection (from database.Search or database.FTSearch)
What I have on my mind is to define some Custom Properties where I can define:
URL that produces the JSON
Object
etc.
So far I'm considering:
REST Service control from ExtLib
XAgent that produces JSON
Domino URL ?ReadViewEntries and OutputFormat=JSON
Does anyone knows if the JSON object loaded in memory has a size limit?
Any suggestion will be appreciated.
Definitely go for the REST Service control from the Extension Library, offers by far the best combination of flexibility vs performance vs development time.
Matt
What about creating the JSON in the view itself and then just read the column values? http://www.eknori.de/2011-07-23/formula-magic/
If you want to parse the json object using ssjs, you can fetch it using an URLConnection and put the resulting object into a repeat control using the eval statement.