0
0
Wordpressframework~10 mins

Theme translation readiness in Wordpress - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to make the theme text translatable using the correct function.

Wordpress
echo [1]('Welcome to my site', 'mytheme');
Drag options to blanks, or click blank then click option'
Atranslate
Bprint
Cecho
D__
Attempts:
3 left
💡 Hint
Common Mistakes
Using echo instead of a translation function.
Using print which is not a translation function.
Using a non-existent function like translate.
2fill in blank
medium

Complete the code to load the theme's text domain for translation.

Wordpress
load_theme_textdomain('mytheme', [1]);
Drag options to blanks, or click blank then click option'
A__DIR__ . '/languages'
Bget_stylesheet_directory() . '/languages'
Cget_template_directory() . '/languages'
D'/wp-content/languages'
Attempts:
3 left
💡 Hint
Common Mistakes
Using __DIR__ which may not work correctly in all cases.
Using get_stylesheet_directory() which points to child theme directory.
Using a hardcoded path that may not be portable.
3fill in blank
hard

Fix the error in this translation function call to correctly escape and translate the text.

Wordpress
echo esc_html_e([1], 'mytheme');
Drag options to blanks, or click blank then click option'
A'Hello World'
BHello World
C"Hello World"
D__('Hello World')
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving the text unquoted causing syntax errors.
Passing a function call inside esc_html_e which is incorrect.
Using double quotes inconsistently.
4fill in blank
hard

Fill both blanks to create a translation-ready string with a placeholder for a dynamic value.

Wordpress
printf( [1], [2] );
Drag options to blanks, or click blank then click option'
A__('Hello %s', 'mytheme')
B'Hello %s'
C$username
Desc_html($username)
Attempts:
3 left
💡 Hint
Common Mistakes
Not translating the string before printing.
Not escaping the dynamic value which can cause security issues.
Using raw variables without quotes or escaping.
5fill in blank
hard

Fill all three blanks to register a theme text domain and load translation files correctly.

Wordpress
function mytheme_setup() {
  load_theme_textdomain([1], [2] . [3]);
}
add_action('after_setup_theme', 'mytheme_setup');
Drag options to blanks, or click blank then click option'
A'mytheme'
Bget_template_directory()
C'/languages/'
D'mytheme-textdomain'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect text domain names.
Not concatenating the path properly.
Using child theme directory instead of template directory.