Internationalisation (i18n) and Localisation (i10n) Flashcards

1
Q

Q: What does internationalisation (i18n) mean?

A

A: Preparing a WordPress theme or plugin to support translation into different languages.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Q: What does localisation (l10n) mean?

A

A: Translating text and adapting other locale-specific elements for a specific region or language.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Q: What is a .POT file?

A

A: A Portable Object Template file used as a template for translations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Q: What is a .PO file?

A

A: A Portable Object file that contains the actual translations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Q: What is a .MO file?

A

A: A Machine Object file, a compiled version of the .PO file used by WordPress.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Q: What is the purpose of __()?

A

A: To translate and return a string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Q: What is _e() used for?

A

A: To translate and echo a string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Q: What does _n() do?

A

A: Handles plural translations for a given string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Q: What is the esc_html__() function used for?

A

A: To translate and escape HTML output for safe display.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Q: What is the esc_attr__() function used for?

A

A: To translate and escape a string for use in HTML attributes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Q: What is a text domain in WordPress?

A

A: A unique identifier for grouping translations in a plugin or theme.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Q: Where do you define the text domain for a theme?

A

A: In the theme’s style.css file under the Text Domain header.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Q: Where do you define the text domain for a plugin?

A

A: In the plugin’s main file within the plugin header comment.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Q: What is the purpose of the load_textdomain() function?

A

A: To load a text domain for translations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Q: How do you load translations for a theme?

A

A: Use load_theme_textdomain().

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Q: What directory is used for language files in a theme?

A

A: /wp-content/themes/your-theme-name/languages/.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Q: What directory is used for language files in a plugin?

A

A: /wp-content/plugins/your-plugin-name/languages/.

18
Q

Q: How do you load translations for a plugin?

A

A: Use load_plugin_textdomain().

19
Q

Q: What is the purpose of get_locale()?

A

A: To get the current locale of the WordPress site.

20
Q

Q: What is the load_textdomain_mofile filter used for?

A

A: To override the path to the .MO file for a text domain.

21
Q

Q: What tool is commonly used to generate .POT files?

A

A: POEdit or WP-CLI’s make-pot command.

22
Q

Q: How do you extract translation strings from a WordPress project?

A

A: Use WP-CLI or tools like Loco Translate.

23
Q

Q: What is the purpose of the msgid and msgstr fields in a .PO file?

A

A: msgid contains the original string, and msgstr contains the translation.

24
Q

Q: What command generates a .POT file with WP-CLI?

A

A: wp i18n make-pot.

25
Q

Q: What happens if a translation is missing in the .MO file?

A

A: The original string (msgid) is displayed as a fallback.

26
Q

Q: What does _n() require to handle plurals?

A

A: Singular and plural forms of the string, along with a number.

27
Q

Q: How do you specify context for plural strings?

A

A: Use the _nx() function.

28
Q

Q: How do you format a call to _n()?

A

printf( _n( ‘%d apple’, ‘%d apples’, $count, ‘text-domain’ ), $count );

29
Q

Q: What is the purpose of _n_noop()?

A

A: To prepare plural strings for later translation.

30
Q

Q: What function combines _n_noop() with context?

A

A: _nx_noop().

31
Q

Q: Why should you avoid hardcoding strings?

A

A: To ensure they are translatable.

32
Q

Q: Why should you always use a text domain?

A

A: To group translations and avoid conflicts.

33
Q

Q: How can you make translation strings easier to manage?

A

A: Use descriptive and meaningful keys in your source code.

34
Q

Q: Why is escaping important in translation functions?

A

A: To prevent XSS vulnerabilities.

35
Q

Q: Why should you provide context for ambiguous strings?

A

A: To ensure accurate translations.

36
Q

Q: How do you enable debugging for translations in WordPress?

A

A: Set define( ‘WP_DEBUG’, true ); and use the WP_LANG_DIR constant to log issues.

37
Q

Q: What function can you use to check if a string is being translated?

A

A: translate() or __().

38
Q

Q: How can you test translations in different locales?

A

A: Change the site language in Settings > General.

39
Q

Q: How do you check if a .MO file is loaded correctly?

A

A: Verify its location and ensure the text domain matches.

40
Q

Q: How can you reload translations without refreshing the browser?

A

A: Use the load_textdomain() function in your code.