- Status
- Vom Autor gelöst
- Gelöst in
- MapPress 2.95.7
- Zugehöriges Plugin/Theme
- MapPress Maps for WordPress
- Themen-Tags
- Compatibility
Übersicht über das Problem
Wenn Sie MapPress mit WPML verwenden, kann es vorkommen, dass Points of Interest (POI) wie auf einer Karte gespeicherte Städte nicht übersetzt werden. Das liegt daran, dass die POI-Strings basierend auf der bei ihrer Erstellung verwendeten Sprache gespeichert werden und nicht automatisch für die Übersetzung verfügbar sind.
Problemumgehung
Bitte stellen Sie sicher, dass Sie ein vollständiges Backup Ihrer Website haben, bevor Sie fortfahren.
- Fügen Sie den folgenden Code zur Datei functions.php Ihres Themes hinzu.
// WPML Workaround for compsupp-4265: Translate Mappress POI fields if ( class_exists('Sitepress') ) { add_action('mappress_map_save', 'my_mappress_register_poi_strings'); function my_mappress_register_poi_strings($map) { $fields = array('address','title','name','body'); if (empty($map->mapid) || empty($map->pois) || !is_array($map->pois)) return; foreach ($map->pois as $i => $poi) { foreach ($fields as $field) { if (isset($poi->$field) && $poi->$field !== '') { $key = "map_{$map->mapid}_poi_{$i}_{$field}"; do_action( 'wpml_register_single_string','mappress', $key, $poi->$field ); } } } } add_action('mappress_map_display', 'my_mappress_translate_poi_fields'); function my_mappress_translate_poi_fields($map) { $fields = array('address','title','name','body'); if (empty($map->mapid) || empty($map->pois) || !is_array($map->pois)) return; foreach ($map->pois as $i => $poi) { foreach ($fields as $field) { if (isset($poi->$field) && $poi->$field !== '') { $key = "map_{$map->mapid}_poi_{$i}_{$field}"; $translated = apply_filters('wpml_translate_single_string', $poi->$field, 'mappress', $key); $poi->$field = $translated; } } } } } - Speichern Sie Ihre Karten unter „MapPress > Maps“ erneut.
- Gehen Sie zu „WPML > String-Übersetzung“ und übersetzen Sie die Strings unter der Domain ‚mappress‘