<?php
namespace Avirtum\GutenDraw\System;

use Avirtum\GutenDraw\Models\SettingsModel;

defined( 'ABSPATH' ) || exit;

class I18n {
    public function __construct() {
        add_action( 'init', [ $this, 'loadTextdomain' ] );
    }

    public function loadTextdomain() {
        if ( function_exists( 'determine_locale' ) ) {
            $locale = determine_locale();
        } else {
            $locale = is_admin() ? get_user_locale() : get_locale();
        }

        load_plugin_textdomain( 'gutendraw', false, dirname( GUTENDRAW_PLUGIN_BASE_NAME ) . '/languages/' );

        unload_textdomain( 'gutendraw' );
        load_textdomain( 'gutendraw', dirname( GUTENDRAW_PLUGIN_BASE_NAME ) . '/languages/gutendraw-' . $locale . '.mo' );
        load_plugin_textdomain( 'gutendraw', false, dirname( GUTENDRAW_PLUGIN_BASE_NAME ) . '/languages/' );
    }

    public static function getTranslation() {
        $translation = [
            'error_network_response' => esc_html__( 'Network response was not ok', 'gutendraw' ),
            'error_unknown' => esc_html__( 'An unknown error occurred', 'gutendraw' ),
            'operation_failed' => esc_html__( 'The operation failed', 'gutendraw' ),
            'operation_success' => esc_html__( 'The operation completed successfully', 'gutendraw' ),
            'upgrade' => esc_html__( 'This is the pro feature.', 'gutendraw' ) . " <a target='_blank' href='" . GUTENDRAW_UPGRADE_URL . "' rel='noreferrer'>" . esc_html__( 'Upgrade to get the full power.', 'gutendraw'  ) . '</a>',
            'limits_diagrams' => esc_html__( 'You can create only 3 diagrams. If you need more, upgrade to the pro version.', 'gutendraw' ),
            'limits_save_settings' => esc_html__( 'The ability to change and save settings is a pro feature.', 'gutendraw' ),
            'close' => esc_html__( 'Close', 'gutendraw' ),
            'publish' => esc_html__( 'Publish', 'gutendraw' ),
            'switch_to_draft' => esc_html__( 'Switch to draft', 'gutendraw' ),
            'save' => esc_html__( 'Save', 'gutendraw' ),
            'sup' => SettingsModel::getSup(),
            'settings_header' => esc_html__( 'Settings', 'gutendraw' ),
            'editor_header' => esc_html__( 'Diagram', 'gutendraw' ),
            'editor_placeholder_title' => esc_html__( 'Add title...', 'gutendraw' ),
            'access'  => esc_html__( 'Permissions', 'gutendraw' ),
            'access_desc' => esc_html__('Use this section to control who can view and edit GutenDraw diagrams. You can choose from three distinct access types to tailor permissions for selected roles:', 'gutendraw' ),
            'access_type_all' => esc_html__( 'All', 'gutendraw' ),
            'access_type_by_role' => esc_html__( 'By Role', 'gutendraw' ),
            'access_type_private' => esc_html__( 'Private', 'gutendraw' ),
            'access_type_all_desc' => esc_html__( 'When this option is selected, users have the ability to view and edit all diagrams based on their rights.', 'gutendraw' ),
            'access_type_by_role_desc' => esc_html__( 'Users can view and edit diagrams based on their assigned role. For example, an editor can see diagrams created by other editors.', 'gutendraw' ),
            'access_type_private_desc' => esc_html__( 'This option ensures that only you, as the owner, can view and edit the diagrams. Rights are also taken into account.', 'gutendraw' ),
            'access_role' => esc_html__( 'Role', 'gutendraw' ),
            'access_type' => esc_html__( 'Access Type', 'gutendraw' ),
            'access_right_view' => esc_html__( 'View', 'gutendraw' ),
            'access_right_create' => esc_html__( 'Create', 'gutendraw' ),
            'access_right_edit' => esc_html__( 'Edit', 'gutendraw' ),
            'access_right_delete' => esc_html__( 'Delete', 'gutendraw' ),
            'access_right_publish' => esc_html__( 'Publish', 'gutendraw' ),
            'block_settings' => esc_html__( 'Settings', 'gutendraw' ),
            'block_select_item' => esc_html__( 'Diagram', 'gutendraw' ),
            'block_show_title' =>  esc_html__( 'Show Title', 'gutendraw' ),
            'block_edit' => esc_html__( 'Edit', 'gutendraw' ),
            'info_title_pro' => esc_html__( 'Congratulations!!!', 'gutendraw' ),
            'info_text_pro' => esc_html__( 'You are using the GutenDraw Pro version.', 'gutendraw' ),
            'info_title_get_pro' => esc_html__( 'Get GutenDraw Pro', 'gutendraw' ),
            'info_text_get_pro' => esc_html__( 'Unlock all features and premium support.', 'gutendraw' ),
            'info_title_youtube' => esc_html__( 'YouTube Channel', 'gutendraw' ),
            'info_text_youtube' => esc_html__( 'Watch our video to learn about all the features of GutenDraw.', 'gutendraw' ),
            'info_title_support' => esc_html__( 'Support', 'gutendraw' ),
            'info_text_support' => esc_html__( 'Quickly get direct help from our qualified support team.', 'gutendraw' ),
            'info_title_suggest' => esc_html__( 'Suggest a Feature', 'gutendraw' ),
            'info_text_suggest' => esc_html__( 'Do you have ideas or suggestions for GutenDraw? We would love to hear them.', 'gutendraw' )
        ];

        return $translation;
    }
}