Tracker names in multiple languages
Added by David Svensson almost 15 years ago
We use the trackers (Bug, Functionality, Other etc.) to track different kinds of issues in our project, much like Redmine.org does. However, we have multiple developers all having different language settings (swedish, norwegian, english) and using english only tracker names confuses some of our clients. Is there a way to translate the tracker names depending on what locale the user is using?
Replies (3)
RE: Tracker names in multiple languages - Added by Felix Schäfer almost 15 years ago
Hello David,
There is currently no way to support locales for the tracker names, because the tracker names are user configurable, and having the localised would mean that you'd have to localise each tracker name you come up with. If you are a little adventurous and know your way around ruby a little bit, I could point you towards what steps would be necessary to make the tracker names localisable, although this would be at your own risk, and would require patching the core somewhat, which in turn could mean more work or even breakage on redmine updates.
RE: Tracker names in multiple languages - Added by David Svensson almost 15 years ago
Sure, give me some tips and I'm sure I'll be able to figure it out.
RE: Tracker names in multiple languages - Added by Felix Schäfer almost 15 years ago
Ok, so just to get the basics out of the way: the function l
is the function redmine internally uses to localise strings, or to be precise, to replace a symbol by a localised string. If e.g. there is a call l(:label_issue_view_all)
, this returns the localised string for label_issue_view_all
as defined in the .yml
of your locale.
The first step to get internationalisation will therefore be to append the symbols/strings you want to localise to the .yml
files, you could do that on the core redmine language files, but it will be easier for future upgrades to put that in a plugin (see the plugin tutorial for more information, feel free to ask if you have any questions). So this gives you $REDMINE_DIR/vendor/plugins/redmine_translate_tracker_names/config/locales/$LOCALE.yml
files, with content of the form:
en: tracker_bug: Bug tracker_feature: Feature tracker_support: SupportFrom here, there are three possibilities:
- either track down each and every time a tracker's name is shown in a view and replace that with something like
l(("tracker_" + the_trackers_name_variable).to_sym)
, that would be the safest, but also the most tedious way, and the trackers would get ordered according to the english names rather than the localised name. - add a method
localised_name
to theTracker
model, and replace all calls toTracker#name
withTracker#localised_name
, as safe as above, but also tedious and a change to the core, - override
Tracker#name
, that would even work from a plugin and wouldn't need any modification to the core (just thought of that while browsing the source). You'd just have to makeTracker#name
look something like that:def name l(("tracker_" + read_attribute(:name).downcase.gsub(/\s/, '_')).to_sym) end
One improvement to this could be to catch cases where no string is defined for this symbol in the desired locale and make it output the name instead of anything localised. Also note that I don't know ifl
functions in models already, to you'd have to try this out on your own.
Ok, I think this is the gist of it, ping me again if you need some more details.