Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Shorter shotcut for a gettext helper #271

wants to merge 2 commits into


None yet
3 participants

lasarux commented Nov 24, 2012

Signature is now ok. Thanks for the reply!


larzconwell commented Dec 17, 2012

I'll merge this, but why is it just called 't'? We should think of a better name, because that's kinda confusing and doesn't explain what it is. Also you'll need to create a entry in docs/5-templates.md

Also sorry for the late response.

lasarux commented Dec 17, 2012

't' is for 'translate' and I would like to avoid confusion with '_', that is a shortcut for gettext(). 'translate' is a long word and it's a bit hard to write it again and again... and again... in templates. Is this fine for you?

@larzconwell larzconwell commented on the diff Dec 18, 2012

@@ -240,3 +240,11 @@ exports.truncateHTML = {
//altName: 'truncate_HTML',
action: utils.string.truncateHTML
+// Simple implementation to use gettext into templates
+exports.t = {
+ name: 't',
+ action: function(key, opts, locale) {
+ return i18n.getText(key, opts || {}, locale);

larzconwell Dec 18, 2012


This will need to be utils.i18n.getText not i18n.getText


larzconwell commented Dec 18, 2012

So I've thought about it, and I don't think we should merge it, we already give users access to getText via geddy.i18n.getText and geddy.utils.i18n.getText. Also users can create their own helpers. Just create a directory at app/helpers(Recently this was added to the generators) then you can create your own helpers to use.

Here's how a helper would look for your translate method: app/helpers/translate.js

exports.t = function (key, opts, locale) {
  return geddy.i18n.getText(key, opts || {}, locale);

Then you can use your t function like normal.


mde commented Dec 18, 2012

Thanks very much for the effort here, in any case. We really appreciate every effort to make Geddy better.


larzconwell commented Dec 18, 2012

+1 Definitely, thanks a bunch @lasarux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment