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
Internalisation feature #9
Comments
I agree it would be ideal to allow just passing in a template string (e.g. using the Smarty template syntax as in your example and as in how the docs explain it). The one reason I would be hesitant is that we then have to build the ability for dynatable to parse out the template (short of writing or requiring the template engine itself into dynatable). I think as a short-term solution, we should just add config options for each part of the the record-count text, so that dynatable can continue just using string concatenation to put the whole thing together. Something like this: inputs: {
recordCountTextShowing: 'Showing ',
recordCountTextTo: ' to ',
recordCountTextOf: ' of ',
recordCountTextFilteredStart: ' (filtered from ',
recordCountTextFilteredEnd: ' total records)'
} Such that the entire string would be concatenated as: # if no query/filter applied
{dataset.recordCountTextShowing} {x} {inputs.recordCountTextTo} {y} {inputs.recordCountTextOf} {z} {params.records}
# if query/filter applied
{dataset.recordCountTextShowing} {x} {inputs.recordCountTextTo} {y} {inputs.recordCountTextOf} {z} {params.records} {recordCountTextFilteredStart} {n} {recordCountTextFilteredEnd} as opposed to how it's currently concatenated, which has most of the text hard-coded: # if no query/filter applied
{dataset.recordCountText} {x} to {y} of {z} {params.records}
# if query/filter applied
{dataset.recordCountText} {x} to {y} of {z} {params.records} (filtered from {n} total records) |
Actually, looking a bit further into it, I think we probably could build a very basic template function that's fast and efficient for what we need. Maybe something along the lines of this StackOverflow post, but changing up the regex to use our more smarty-like syntax (which I prefer). |
The regex looks like the perfect solution. |
Internalisation? I assume you mean Internationalization? (Or internationalisation, to give a localized version :) .) |
Yes I wanted to say internationalization sorry ! |
No problem. I didn't mean to be correcting so much as clarifying. |
I've now added full customization to the record-count text. The new configuration options with defaults are: inputs: {
recordCountPageBoundTemplate: '{pageLowerBound} to {pageUpperBound} of',
recordCountPageUnboundedTemplate: '{recordsShown} of',
recordCountTotalTemplate: '{recordsQueryCount} {collectionName}',
recordCountFilteredTemplate: ' (filtered from {recordsTotal} total records)',
recordCountText: 'Showing',
recordCountTextTemplate: '{text} {pageTemplate} {totalTemplate} {filteredTemplate}'
} The main option above is You can define your own templates using any of the variables above, which correspond to:
|
Hi @JangoSteve , I'm trying to translate the Dynatable to Portuguese as your explanation above, but I'm not getting it.
I took a look at the source code and I think the problem is between the lines 707 and 737. Similar to pageLinks += ' |
I think it would be a good idea to add internalisation to dynatable.
At the moment we can only overwrite some words in the inputs:{} default configuration object.
Maybe we could use some sentences to parse like :
inputs: {
recordCountText: 'Showing {x} to {y} of {z} records'
}
The text was updated successfully, but these errors were encountered: