Esempio n. 1
0
File: loco.php Progetto: epiii/aros
 function loco_after_setup_theme()
 {
     if (is_user_logged_in()) {
         loco_require('loco-boot');
         if (current_user_can(Loco::CAPABILITY)) {
             // @todo font end functionality
         }
     }
 }
Esempio n. 2
0
 function loco_after_setup_theme()
 {
     if (is_user_logged_in()) {
         loco_require('loco-boot');
         //if( current_user_can( Loco::admin_capablity() ) ){
         // TODO font end functionality
         //}
     }
 }
Esempio n. 3
0
<?php

/**
 * Admin ajax include that syncs PO or POT file with sources
 */
DOING_AJAX or die;
if (empty($path) || !isset($name) || empty($type)) {
    throw new Exception(Loco::__('Invalid data posted to server'), 422);
}
// path is allowed to not exist yet
if ('/' !== $path[0]) {
    $path = WP_CONTENT_DIR . '/' . $path;
}
// but package must exist so we can get POT or source
/* @var $package LocoPackage */
loco_require('loco-packages', 'loco-locales');
$package = LocoPackage::get($name, $type);
if (!$package) {
    throw new Exception(sprintf(Loco::__('Package not found called %s'), $name), 404);
}
while (true) {
    // If file we're syncing is POT, we can only sync from sources
    if (!LocoAdmin::is_pot($path)) {
        // if a POT file exists, sync from that
        $domain = LocoAdmin::resolve_file_domain($path) or $domain = $package->get_domain();
        if ($pot_path = $package->get_pot($domain)) {
            $exp = LocoAdmin::parse_po($pot_path);
            if (!$exp || 1 === count($exp) && '' === $exp[0]['source']) {
                // throw new Exception( Loco::__('POT file is empty').' - '.basename($pot_path) );
                // fall through to try source code
            } else {
Esempio n. 4
0
 /**
  * Execute native msgfmt command
  * @param string po source
  * @return string binary mo source
  */
 public static function msgfmt_native($po)
 {
     try {
         $conf = Loco::config();
         loco_require('build/gettext-compiled');
         $gen_hash = (bool) $conf['gen_hash'];
         $use_fuzzy = (bool) $conf['use_fuzzy'];
         $mo = loco_msgfmt($po, $gen_hash, $use_fuzzy);
     } catch (Exception $Ex) {
         error_log($Ex->getMessage(), 0);
     }
     if (!$mo) {
         throw new Exception(sprintf(Loco::__('Failed to compile MO file with built-in compiler')));
     }
     return $mo;
 }
Esempio n. 5
0
 /**
  * @return array
  */
 private static function data()
 {
     static $data;
     if (!isset($data)) {
         // this must be the first include of this file to ensure it returns
         $data = loco_require('build/locales-compiled');
     }
     return $data;
 }
Esempio n. 6
0
    // noop
}
function do_action($name)
{
    did_action($name, true);
}
function did_action($name)
{
    static $faked = array();
    if (2 === func_num_args()) {
        $faked[$name] = func_get_arg(1);
    }
    return isset($faked[$name]) ? $faked[$name] : false;
}
function apply_filters($hook, $value = null)
{
    return $value;
}
function get_locale()
{
    return 'en_US';
}
function __($t)
{
    return $t;
}
define('WP_DEBUG', true);
define('WP_PLUGIN_DIR', __DIR__ . '/../../..');
require __DIR__ . '/../../loco.php';
loco_require('loco-boot', 'loco-admin', 'loco-locales', 'loco-packages', 'build/gettext-compiled', 'build/shell-compiled', 'compat/loco-tokenizer', 'compat/loco-mbstring', 'compat/loco-iconv', 'compat/loco-json', 'compat/loco-php');
Esempio n. 7
0
while (!$ispot) {
    try {
        // check target MO path before compiling
        $mopath = preg_replace('/\\.po$/', '.mo', $path);
        if (!file_exists($mopath) && !is_writable(dirname($mopath))) {
            throw new Exception(Loco::__('Cannot create MO file'));
        } else {
            if (file_exists($mopath) && !is_writable($mopath)) {
                throw new Exception(Loco::__('Cannot overwrite MO file'));
            }
        }
        // attempt to compile MO direct to file via shell
        if ($msgfmt = LocoAdmin::msgfmt_command()) {
            try {
                $bytes = 0;
                loco_require('build/shell-compiled');
                define('WHICH_MSGFMT', $msgfmt);
                $mopath = loco_compile_mo_file($path, $mopath);
                $bytes = $mopath && file_exists($mopath) ? filesize($mopath) : 0;
            } catch (Exception $Ex) {
                error_log($Ex->getMessage(), 0);
            }
            if (!$bytes) {
                throw new Exception(sprintf(Loco::__('Failed to compile MO file with %s, check your settings'), WHICH_MSGFMT));
            }
            $response['compiled'] = $bytes;
            break;
        }
        // Fall back to in-built MO compiler - requires PO is parsed too
        $mo = LocoAdmin::msgfmt_native($po);
        $bytes = file_put_contents($mopath, $mo);
Esempio n. 8
0
<?php

/**
 * Admin ajax include that returns compiled-in data
 * Included by loco-ajax.php during Ajax action
 */
DOING_AJAX or die;
// default is single locale response
if (isset($locale)) {
    loco_require('loco-locales');
    $data = loco_locale_resolve($locale);
    return array('locales' => array($locale => $data->export()));
}
throw new Exception(Loco::__('Invalid data posted to server'), 422);
Esempio n. 9
0
Author: Tim Whitlock
Version: 1.5.5
Author URI: https://localise.biz/help/wordpress/translate-plugin
Text Domain: loco-translate
Domain Path: /languages/
*/
/**
 * Avoid conflict with version 2.0
 */
if (function_exists('loco_include')) {
    return;
}
/** 
 * Include a component from lib subdirectory
 * @param string $subpath e.g. "loco-admin"
 * @return mixed value from last included file
 */
function loco_require()
{
    static $dir;
    isset($dir) or $dir = dirname(__FILE__);
    $ret = '';
    foreach (func_get_args() as $subpath) {
        $ret = (require_once $dir . '/lib/' . $subpath . '.php');
    }
    return $ret;
}
// Inialize admin screen
if (function_exists('is_admin') && is_admin()) {
    loco_require('loco-boot', 'loco-admin');
}
Esempio n. 10
0
{
    return false;
}
function esc_html($text)
{
    return htmlspecialchars($text, ENT_COMPAT, 'UTF-8');
}
function add_action()
{
    // noop
}
function add_filter()
{
    // noop
}
function apply_filters($hook, $value = null)
{
    return $value;
}
function get_locale()
{
    return 'en_US';
}
function __($t)
{
    return $t;
}
define('WP_DEBUG', true);
require __DIR__ . '/../../loco.php';
loco_require('loco-boot', 'loco-admin', 'loco-locales', 'loco-packages', 'build/gettext-compiled', 'build/shell-compiled');