WordPressMVC

  1. Get Started
  2. Documentation
  3. Tutorials
  4. Blog
  1. Documentation
  2. Tutorials
Login
  • Blog
  • Download
  • Get Started
  • The Basics
    • Ayuco
    • Main Class
    • Configuration
  • Hooks
    • Actions
    • Filters
    • Widgets
    • Shortcodes
  • MVC
    • Models
    • Post Models
    • Option Models
    • Term Models
    • User Models
    • Views
    • Controllers
  • Resources
    • Assets
    • Styles
    • Scripts
  • Advanced
    • Request
    • Response
    • Localization
    • Cache
    • Logger
    • Database
    • Testing
    • Deployment
    • Functions
    • Add-ons

Localization

Last updated: January 12, 2020

The framework supports WordPress localization files (POT and PO files).

By default, localization files should be stored in the folder [path to project]/assets/lang.

Text Domain

Localization in WordPress works by text domains. These domains are attached to each custom text string found inside the code of a plugin or theme and help WordPress who will translate them.

WordPress expects the domain owner to provide it with PO language files that will be used for translations.

Define your text-domain based on your namespace. WordPress.org will assign you a text-domain (slug) if you plan to publish the project on their website.

Ayuco Command

Ayuco asks for a text-domain during the setup command.

Alternatively, the text domain can be changed by using the set command:

php ayuco set domain:{text-domain}

Configuration

Localization settings can be modified in the configuration file.

return [
    // Other settings ...
    'localize' => [
        // Enables or disables localization
        'enabled'       => false,
        // Default path for language files
        'path'          => __DIR__ . '/../../assets/lang/',
        // Text domain
        'textdomain'    => 'my-app',
        // Unload loaded locale files before localization
        'unload'        => false,
        // Flag that indicates if this is a WordPress.org plugin/theme
        'is_public'     => false,
    ],
    // Other settings ...
];
Do not change the text-domain manually, use Ayuco instead.
© 2021 10 Quality Studio . All rights reserved.
Search in: