Translating messages inside Javascript files

16 views
Skip to first unread message

Lanfio Orelli

unread,
Mar 24, 2023, 1:00:15 PM3/24/23
to Xataface
While it is possible to use df_translate() and {translate ...} to do i18n on messages in Xataface php scripts, it's not clear to me how I could achieve the same in Xataface Javascript scripts.
Could you please help me ?
Reagards

Steve Hannah

unread,
Mar 25, 2023, 10:54:33 AM3/25/23
to xata...@googlegroups.com
You can use the Dataface_Application::addJSStrings() method to push translations up to Javascript for their use.
Then use the xataface.lang object.

Examples: 

Adding strings:
$app->addJSStrings(array(
   'themes.g2.VIEW_SEARCH_RESULTS' => df_translate('themes.g2.VIEW_SEARCH_RESULTS', 'View Search Results'),
   'themes.g2.SEARCH_RESULTS' => df_translate('themes.g2.SEARCH_RESULTS', 'Search Results'),
   'findwidgets.date.from' => df_translate('findwidgets.date.from', 'From'),
   'findwidgets.date.to' => df_translate('findwidgets.date.to', 'to')
));

Using strings from javascript:


--
You received this message because you are subscribed to the Google Groups "Xataface" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xataface+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xataface/3e2828bc-c26e-4a3a-a796-4a4b6e293135n%40googlegroups.com.


--
Steve Hannah
Web Lite Solutions Corp.

Lanfio Orelli

unread,
Mar 25, 2023, 11:16:11 AM3/25/23
to Xataface
Thank you very much
Reply all
Reply to author
Forward
0 new messages