Translating Custom Fields
This Doc describes how to translate the custom fields you can configure in the GeoDirectory Settings.
If you only use one language on your site, you can still use this process to change some field labels and descriptions that are built-in.
Follow the steps below each time you update the custom fields settings on your site with new fields.
Translating Custom Fields with POEdit
- Run the DB Translation tool at GeoDirectory - > Status - > Tools - > DB Text Translation to create the db-language.php file
- Find file called db-language.php that you will find in your geodirectory folder on the server.
- Copy all files in the geodirectory folder to your computer:
- Open the /wp-content/plugins/geodirectory/geodirectory-languages/geodirectory-en_US.po file with poEdit:
-
From the catalogue menu, choose Update from sources ...:
-
That will re-build the geodirectory-en_US.po file:
- Save the file.
- You now have a new base language file including the new custom fields. You can now use that file to create your other language files, read more at How To Translate Or Localize GeoDirectory
Translating AUI Strings
To translate calendar strings, Select2 strings and "time ago" strings please add the following PHP snippet. We recommend the Code Snippets plugin for adding snippets.
/** * Translate AUI calendar strings. */ function gd_snippet_ui_calendar_params( $params ) { foreach ( $params as $key => $string ) { $string = __( $string ); $string = __( $string, 'geodirectory' ); $params[ $key ] = $string; } return $params; } add_filter( 'ayecode_ui_calendar_params', 'gd_snippet_ui_calendar_params', 21, 1 ); /** * Translate AUI select2 strings. */ function gd_snippet_aui_translate_select2( $params ) { $_params = geodir_params( 'geodir-select2' ); foreach ( $_params as $key => $string ) { if ( isset( $params[ $key ] ) ) { $params[ $key ] = $string; } } return $params; } add_filter( 'ayecode_ui_select2_params', 'gd_snippet_aui_translate_select2', 10, 1 ); /** * Translate AUI time ago strings. */ function gd_snippet_aui_translate_timeago( $params ) { $geodir_params = geodir_params(); foreach ( $geodir_params['time_ago'] as $key => $string ) { if ( isset( $params[ $key ] ) ) { $params[ $key ] = $string; } } return $params; } add_filter( 'ayecode_ui_timeago_params', 'gd_snippet_aui_translate_timeago', 10, 1 );