question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is possible to translate columns title?

See original GitHub issue

Is there a way to translate title strings from table headers ?

I’m using tap-i18n, I have also tried to call a function like:

tap = function (str) {
    return (Meteor.isClient) ? TAPi18n.__(str)  : " ";
}
... and then use
{ data: "someField", title: tap('name') }

but nothing is translated, it returns “name”.

Thanks

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
dwimbergercommented, Feb 25, 2017

See #115 Recent versions of aldeed:tabular / datatables allow to specify a function for setting the column titles.

import {TAPi18n} from 'meteor/tap:i18n';

TabularTables = {};
TabularTables.Departments= new Tabular.Table({
  name: 'Departments',
  collection: Departments,
 responsive: true,
 autoWidth: true,
 stateSave: false,
 columns: [
    {data: "name", titleFn: function() {
      return TAPi18n.__("name");
    }},
    {data: "description", titleFn: function() {
      return TAPi18n.__("description");
    }}
  ]
});

The language change is reactive. If you have translations you can switch and columns will be translated.

TAPi18n.setLanguage("en");
TAPi18n.setLanguage("de");

Word of warning: This currently does not work when you include invisible columns in your table data. The offset is wrong and you get wrong column titles.

1reaction
ixdicommented, Jan 21, 2015

It’s ok if using

Template.<name>.rendered = function () {
     _.each($('thead tr th'), function (o) {
           $(o).html(TAPi18n.__($(o).html()));
     });
}

and setting title of each column as the string you have defined inside i18n.

I haven’t found a direct method, without the need to use Template rendered callback.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Translate a table column name - Kofax Product Documentation
Translate a table column name · On the Project tab, in the Configuration group, select Project Settings · Click the Tables tab to...
Read more >
Translate report region column titles - Oracle Communities
Does anyone know if it's possible to translate the titles of the columns of a report region.
Read more >
Translate Board Column Headers - Atlassian Community
Unfortunately, the column names are not currently available for translate. Only issue type, status, resolution and priorities are available for translate. https ...
Read more >
SharePoint: Properly translate your list column names
Don't pluralize it, unless the columns allow multiple selections; Make it as clear as possible, even if the name becomes big. Why all...
Read more >
Pandas Change Column Names – 3 Methods
The first method that we suggest is using Pandas Rename. Rename takes a dict with a key of your old column name and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found