WPML
상태
해결됨
보고된 제품
WPML Multilingual CMS 4.6.4
관련 플러그인/테마
The Events Calendar
주제 태그
Compatibility

문제 개요

특정 상황에서 WPML과 함께 The Events Calendar (TEC) 플러그인을 사용할 때 달력 링크 번역 처리 방식에 불일치가 발생합니다. 예상한 번역 용어가 표시되는 대신, 예를 들어 날짜 링크가 (/?:month|monat|miesic|….)와 같이 잘못 표시됩니다.

참고: 이 문제는 해결되었어야 합니다. 하지만 최근에 유사한 보고가 있었습니다.

임시 해결 방법

진행하기 전에 사이트의 전체 백업을 완료하세요.


  • 사용자 > 프로필로 이동하여 기본 언어를 사용자 언어로 설정하세요.

  • 설정 > 고유주소로 이동하여 다시 저장하세요. 때로는 이 작업만으로 문제가 해결됩니다.

  • 문제가 해결되지 않으면 functions.php 파일에 다음 코드를 추가하세요:
    /*
    *  WPML Workaround for compsupp-6815
    */
    add_filter( 'tribe_rewrite_canonical_url', 'wpml_compsupp6815_resolve_missing_urls', 10, 3 );
    
    function wpml_compsupp6815_resolve_missing_urls( $resolved, $url, $object ) {
    
    	if ( class_exists('Sitepress') ) {
    		$wpml_default_lang = apply_filters('wpml_default_language', NULL );
    		$wpml_current_lang = apply_filters( 'wpml_current_language', NULL );
    		
    		// Let's register the calendar strings so we can translate and use in the workaround
    		if ($wpml_default_lang == $wpml_current_lang ) {
    			
    			$events_slug = $tec_options['eventsSlug'];	
    			$single_events_slug = $tec_options['singleEventSlug']; 
    			$tec_options = get_option('tribe_events_calendar_options');
    					
    			do_action( 'wpml_register_single_string', 'the-events-calendar', 'TEC Calendar Slugs: '.substr($events_slug, 0, 20), $events_slug);
    			do_action( 'wpml_register_single_string', 'the-events-calendar', 'TEC Calendar Slugs: '.substr($single_events_slug, 0, 20), $single_events_slug );
    			
    			foreach ($tec_options['tribeEnableViews'] as $calendar_string) {
    				do_action( 'wpml_register_single_string', 'the-events-calendar', 'TEC Calendar Slugs: '.substr($calendar_string, 0, 20), $calendar_string);
    			}
    		}
    
    		// Check if the URL is not resolved yet. If not, we will resolve it with the translated strings
    		if ( preg_match( '#/(/?:.+)#',  $resolved ) ) {
    
    			$resolved = preg_replace_callback( '#/(/?:.+?)#', function($matches) use ($url) {
    				$options = explode('|', trim($matches[0], '/(?:)'));
    				
    				$slug = $options[0];					
    
    				$translated_slug = apply_filters('wpml_translate_single_string', $slug , 'the-events-calendar', 'TEC Calendar Slugs: '.substr($slug, 0, 20) );
    
    				// Only apply the translation if the string already exists in the URL. If not, replace with the original. This may avoid possible 404 errors
    				if (in_array(strtolower($translated_slug), $options) && $translated_slug != '') {
    					$slug = $translated_slug;
    				} 
    
    				return '/' . $slug;
    
    			}, $resolved );
    			
    		}
    	}
    
        return $resolved;
    }
  • 설정 > 고유주소로 이동하여 다시 저장하세요.
  • 그런 다음, 프런트엔드에서 각 언어의 고유주소가 어떻게 작동하는지 확인하세요.
  • 문제가 계속 발생하면 아직 번역되지 않은 문자열이 있을 수 있습니다. 이 경우 WPML > 문자열 번역으로 이동하여 텍스트 도메인이 the-events-calendar이고 이름이 TEC Calendar Slugs: ****인 문자열을 번역하세요.

알려진 모든 문제 →