compound icon indicating copy to clipboard operation
compound copied to clipboard

undefined t.locale at view files

Open lovejaco opened this issue 13 years ago • 4 comments

<%= t.('lang') %> method is fine

t.locale is undefined

lovejaco avatar Dec 29 '12 05:12 lovejaco

As far as I remember it should be undefined, unless not set in controller (setLocale).

On Sat, Dec 29, 2012 at 9:27 AM, Sung Yeol Yim [email protected]:

<%= t.('lang') %> method is fine

t.locale is undefined

— Reply to this email directly or view it on GitHubhttps://github.com/1602/compound/issues/306.

anatoliychakkaev avatar Dec 29 '12 10:12 anatoliychakkaev

thanks but i already set in controller

my debug code in setLocale method does not work because this._t is undefined

Controller.prototype.setLocale = function (locale) { if (this._t) { this._t.locale = locale; } };

lovejaco avatar Jan 03 '13 02:01 lovejaco

I think the function "HelperSet()" in helpers.js is miss property as follow:

.. function HelperSet(ctl) { this.controller = ctl; ... this.t = ctl.t.bind(ctl);

this.t.locale = ''   // HERE 

...

Therefore, the view could not get the property 't.locale'

Any thoughts?

lovejaco avatar Jan 03 '13 07:01 lovejaco

I've published fix in newest release:

diff --git a/lib/helpers.js b/lib/helpers.js
index 0182d91..f4a907f 100644
--- a/lib/helpers.js
+++ b/lib/helpers.js
@@ -55,6 +55,7 @@ function HelperSet(ctl) {
         this.actionName = ctl.actionName;
         this.pathTo = this.path_to = ctl.compound.routeMapper.pathTo;
         this.t = ctl.t.bind(ctl);
+        this.t.locale = ctl._t && ctl._t.locale;
     }

1602 avatar Jan 04 '13 23:01 1602