Quantcast

Language in Grid

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Language in Grid

stevepiercy
I noticed there is this comment in the TODO list for grid.inc
(8) and knop_grid.lasso (9):

     Language of quicksearch buttons can't be changed after the
grid has been
     created

Yup, they sure can't.  To fix that, what would be the "best"
method, if any method is possible?

There are instance variables for languages:

     'lang'=(knop_lang: -default='en', -fallback),       //
language strings object
     'error_lang'=(knop_lang: -default='en', -fallback),

...where oncreate allows one to set the default language with -language.

Then when it comes time to render stuff, here is an example:

             (self -> 'quicksearch_form') -> (addfield:
-type='submit', -name='s', -value=(#lang -> quicksearch_search));

Thinking out loud, here's what I propose:
* Move the values of the instance variables from grid.inc into cfg__lang.inc.
* Pass a reference to the language objects from cfg__lang.inc
into the grid with a new parameter -use_lang_ui.
* Remove the instance variable #lang in the define_type, and
instead of doing this in oncreate:

         local: 'lang'=@(self -> 'lang');

     do this:

         local: 'lang'=#use_lang_ui;

* Finally, render like so:

             (self -> 'quicksearch_form') -> (addfield:
-type='submit', -name='s', -value=(#lang -> getstring(-key='quicksearch_search')));

Comments?

--steve

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Steve Piercy               Web Site Builder              
Soquel, CA
<[hidden email]>                  <http://www.StevePiercy.com/>


--
#############################################################
This message is sent to you because you are subscribed to
the mailing list <[hidden email]>.
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
List archive http://lasso.2283332.n4.nabble.com/Knop-Framework-Discussion-f3157831.html
The Knop project and code is hosted at GitHub.
https://github.com/knop-project/knop
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Language in Grid

stevepiercy
I played around a bit more with this concept, and I got it
working.  However to maintain backward compatibility, I propose:

* Copy the values of the instance variables from grid.inc into
cfg__lang.inc, merging into $lang_ui.
* Pass a reference to the language objects from cfg__lang.inc
into the grid with a new parameter -use_lang_ui in the oncreate
method.  (I am also considering passing an array of knop_lang
objects, but that may be overkill.)
* In the oncreate method, modify the code by inserting new lines:

     if(local_defined('use_lang_ui'));
         // override #lang if #use_lang_ui is defined
         local('lang'=#use_lang_ui);
     else;
         local: 'lang'=@(self -> 'lang'); // currently exists
     /if;

* Leave rendering as is.
* Then when creating a grid:

     // create grid object for the record list
     var: 'list'=(knop_grid:
             -database=$d,
             -nav=$nav,
             -quicksearch=$lang_ui -> name,
             -use_lang_ui=$lang_ui, // new parameter
             -language=$s_lang,
             -numbered);

See screenshot for result.

--steve


On 1/20/14 at 1:42 PM, [hidden email] (Steve Piercy - Web
Site Builder) pronounced:

>I noticed there is this comment in the TODO list for grid.inc (8) and knop_grid.lasso (9):
>
>Language of quicksearch buttons can't be changed after the grid has been
>created
>
>Yup, they sure can't.  To fix that, what would be the "best" method, if any method is possible?
>
>There are instance variables for languages:
>
>'lang'=(knop_lang: -default='en', -fallback),       // language strings object
>'error_lang'=(knop_lang: -default='en', -fallback),
>
>...where oncreate allows one to set the default language with -language.
>
>Then when it comes time to render stuff, here is an example:
>
>(self -> 'quicksearch_form') -> (addfield: -type='submit',
>-name='s', -value=(#lang -> quicksearch_search));
>
>Thinking out loud, here's what I propose:
>* Move the values of the instance variables from grid.inc into cfg__lang.inc.
>* Pass a reference to the language objects from cfg__lang.inc
>into the grid with a new parameter -use_lang_ui.
>* Remove the instance variable #lang in the define_type, and instead of doing this in oncreate:
>
>local: 'lang'=@(self -> 'lang');
>
>do this:
>
>local: 'lang'=#use_lang_ui;
>
>* Finally, render like so:
>
>(self -> 'quicksearch_form') -> (addfield: -type='submit',
>-name='s', -value=(#lang -> getstring(-key='quicksearch_search')));
>
>Comments?
>
>--steve
>
>-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>Steve Piercy               Web Site Builder               Soquel, CA
><[hidden email]>                  <http://www.StevePiercy.com/>
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Steve Piercy               Web Site Builder              
Soquel, CA
<[hidden email]>                  <http://www.StevePiercy.com/>
--
#############################################################
This message is sent to you because you are subscribed to
the mailing list <[hidden email]>.
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
List archive http://lasso.2283332.n4.nabble.com/Knop-Framework-Discussion-f3157831.html
The Knop project and code is hosted at GitHub.
https://github.com/knop-project/knop

busque_search_grid_button.png (33K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Language in Grid

stevepiercy
This feature has now been implemented.

knop.lasso is backward compatible.

The new parameter is -langobject and accepts a knop_lang
object.  This allows grid element language strings in the
language configuration file (cfg__lang.inc) to override those
defined as instance variables in the knop_grid type.  In other
words, you can now set values for buttons and other grid elements.

To see it in action, you can visit:
http://www.norcalreferees.com/suspensions/

--steve


On 1/20/14 at 6:30 PM, [hidden email] (Steve Piercy - Web
Site Builder) pronounced:

>I played around a bit more with this concept, and I got it
>working.  However to maintain backward compatibility, I propose:
>
>* Copy the values of the instance variables from grid.inc into
>cfg__lang.inc, merging into $lang_ui.
>* Pass a reference to the language objects from cfg__lang.inc
>into the grid with a new parameter -use_lang_ui in the oncreate
>method.  (I am also considering passing an array of knop_lang
>objects, but that may be overkill.)
>* In the oncreate method, modify the code by inserting new lines:
>
>if(local_defined('use_lang_ui'));
>// override #lang if #use_lang_ui is defined
>local('lang'=#use_lang_ui);
>else;
>local: 'lang'=@(self -> 'lang'); // currently exists
>/if;
>
>* Leave rendering as is.
>* Then when creating a grid:
>
>// create grid object for the record list
>var: 'list'=(knop_grid:
>-database=$d,
>-nav=$nav,
>-quicksearch=$lang_ui -> name,
>-use_lang_ui=$lang_ui, // new parameter
>-language=$s_lang,
>-numbered);
>
>See screenshot for result.
>
>--steve
>
>
>On 1/20/14 at 1:42 PM, [hidden email] (Steve Piercy - Web
>Site Builder) pronounced:
>
>>I noticed there is this comment in the TODO list for grid.inc (8) and knop_grid.lasso
>(9):
>>
>>Language of quicksearch buttons can't be changed after the grid has been
>>created
>>
>>Yup, they sure can't.  To fix that, what would be the "best" method, if any method is
>possible?
>>
>>There are instance variables for languages:
>>
>>'lang'=(knop_lang: -default='en', -fallback),       // language strings object
>>'error_lang'=(knop_lang: -default='en', -fallback),
>>
>>...where oncreate allows one to set the default language with -language.
>>
>>Then when it comes time to render stuff, here is an example:
>>
>>(self -> 'quicksearch_form') -> (addfield: -type='submit',
>>-name='s', -value=(#lang -> quicksearch_search));
>>
>>Thinking out loud, here's what I propose:
>>* Move the values of the instance variables from grid.inc into cfg__lang.inc.
>>* Pass a reference to the language objects from cfg__lang.inc
>>into the grid with a new parameter -use_lang_ui.
>>* Remove the instance variable #lang in the define_type, and instead of doing this in
>oncreate:
>>
>>local: 'lang'=@(self -> 'lang');
>>
>>do this:
>>
>>local: 'lang'=#use_lang_ui;
>>
>>* Finally, render like so:
>>
>>(self -> 'quicksearch_form') -> (addfield: -type='submit',
>>-name='s', -value=(#lang -> getstring(-key='quicksearch_search')));
>>
>>Comments?
>>
>>--steve
>>
>>-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>>Steve Piercy               Web Site Builder               Soquel, CA
>><[hidden email]>                  <http://www.StevePiercy.com/>
>
>-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>Steve Piercy               Web Site Builder               Soquel, CA
><[hidden email]>                  <http://www.StevePiercy.com/>
>
>-----

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy              Website Builder              Soquel, CA
<[hidden email]>               <http://www.StevePiercy.com/>


--
#############################################################
This message is sent to you because you are subscribed to
the mailing list <[hidden email]>.
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
List archive http://lasso.2283332.n4.nabble.com/Knop-Framework-Discussion-f3157831.html
The Knop project and code is hosted at GitHub.
https://github.com/knop-project/knop
Loading...