Index: openacs-4/packages/acs-core-docs/www/xml/developers-guide/i18n.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/xml/developers-guide/i18n.xml,v diff -u -N -r1.6.2.5 -r1.6.2.6 --- openacs-4/packages/acs-core-docs/www/xml/developers-guide/i18n.xml 2 Feb 2004 18:07:47 -0000 1.6.2.5 +++ openacs-4/packages/acs-core-docs/www/xml/developers-guide/i18n.xml 27 Feb 2004 10:02:08 -0000 1.6.2.6 @@ -189,16 +189,18 @@ - Dynamic key lookup: [lang::util::localize $var_with_embedded_message_keys] - In this case the message keys in the variable var_with_embedded_message_keys must appear as string literals \#package_key.message_key\# somewhere in the code. Here is an example of a dynamic lookup: - - - set message_key_array { - dynamic_key_1 \#package_key.message_key1\# - dynamic_key_2 \#package_key.message_key2\# - } + Dynamic key lookup: + +[lang::util::localize $var_with_embedded_message_keys] +- In this case the message keys in the variable var_with_embedded_message_keys must appear as string literals \#package_key.message_key\# somewhere in the code. Here is an example of a dynamic lookup: +set message_key_array { + dynamic_key_1 \#package_key.message_key1\# + dynamic_key_2 \#package_key.message_key2\# +} - set my_text [lang::util::localize $message_key_array([get_dynamic_key])] - +set my_text [lang::util::localize $message_key_array([get_dynamic_key])] + + @@ -210,18 +212,20 @@ enclosed in double quotes. The following is an example of grep commands that can be used on Linux to highlight translatable text in TCL files: + +# Find text in double quotes +find -iname '*.tcl'|xargs egrep -i '"[a-z]' - - # Find text in double quotes - find -iname '*.tcl'|xargs egrep -i '"[a-z]' - # Find untranslated text in form labels, options and values - find -iname '*.tcl'|xargs egrep -i '\-(options|label|value)'|egrep -v '<#'|egrep -v '\-(value|label|options)[[:space:]]+\$[a-zA-Z_]+[[:space:]]*\\?[[:space:]]*$' - # Find text in page titles and context bars - find -iname '*.tcl'|xargs egrep -i 'set (title|page_title|context_bar) '|egrep -v '<#' - # Find text in error messages - find -iname '*.tcl'|xargs egrep -i '(ad_complain|ad_return_error)'|egrep -v '<#' - +# Find untranslated text in form labels, options and values +find -iname '*.tcl'|xargs egrep -i '\-(options|label|value)'|egrep -v '<#'|egrep -v '\-(value|label|options)[[:space:]]+\$[a-zA-Z_]+[[:space:]]*\\?[[:space:]]*$' +# Find text in page titles and context bars +find -iname '*.tcl'|xargs egrep -i 'set (title|page_title|context_bar) '|egrep -v '<#' + +# Find text in error messages +find -iname '*.tcl'|xargs egrep -i '(ad_complain|ad_return_error)'|egrep -v '<#' + + You may mark up translatable text in TCL library files and TCL pages with temporary tags on the <#key text#> syntax. @@ -271,29 +275,31 @@ our example becomes: - - set msg_subst_list [list subject [parameter::get -localize -parameter classes_pretty_name] - class_instances [parameter::get -localize -parameter class_instances_pretty_plural]] + +set msg_subst_list [list subject [parameter::get -localize -parameter classes_pretty_name] class_instances [parameter::get -localize -parameter class_instances_pretty_plural]] - ad_return_complaint 1 [_ dotlrn.class_may_not_be_deleted $msg_subst_list] - +ad_return_complaint 1 [_ dotlrn.class_may_not_be_deleted $msg_subst_list] + + When we were done going through the tcl files we ran the following commands to check for mistakes: - - # Message tags should usually not be in curly braces since then the message lookup may not be - # executed then (you can usually replace curly braces with the list command). Find message tags - # in curly braces (should return nothing, or possibly a few lines for inspection) - find -iname '*.tcl'|xargs egrep -i '\{.*<#' - # Check if you've forgotten space between default key and text in message tags (should return nothing) - find -iname '*.tcl'|xargs egrep -i '<#_[^ ]' - # Review the list of tcl files with no message lookups - for tcl_file in $(find -iname '*.tcl'); do egrep -L '(<#|\[_)' $tcl_file; done - + +# Message tags should usually not be in curly braces since then the message lookup may not be +# executed then (you can usually replace curly braces with the list command). Find message tags +# in curly braces (should return nothing, or possibly a few lines for inspection) +find -iname '*.tcl'|xargs egrep -i '\{.*<#' +# Check if you've forgotten space between default key and text in message tags (should return nothing) +find -iname '*.tcl'|xargs egrep -i '<#_[^ ]' + +# Review the list of tcl files with no message lookups +for tcl_file in $(find -iname '*.tcl'); do egrep -L '(<#|\[_)' $tcl_file; done + + When you feel ready you may vist your package in the package manager