本文整理汇总了PHP中GP_Locales类的典型用法代码示例。如果您正苦于以下问题:PHP GP_Locales类的具体用法?PHP GP_Locales怎么用?PHP GP_Locales使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GP_Locales类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setUp
function setUp()
{
$this->w = new GP_Builtin_Translation_Warnings();
$this->bg = GP_Locales::by_slug('bg');
$this->longer_than_20 = 'The little boy hid behind the counter and then came the wizard of all green wizards!';
$this->shorter_than_5 = 'Boom';
}
开发者ID:rmccue,项目名称:GlotPress,代码行数:7,代码来源:test_builtin_warnings.php
示例2: single
function single($project_path)
{
$project = GP::$project->by_path($project_path);
if (!$project) {
return $this->die_with_404();
}
$sub_projects = $project->sub_projects();
$translation_sets = GP::$translation_set->by_project_id($project->id);
foreach ($translation_sets as $set) {
$locale = GP_Locales::by_slug($set->locale);
$set->name_with_locale = $set->name_with_locale();
$set->current_count = $set->current_count();
$set->untranslated_count = $set->untranslated_count();
$set->waiting_count = $set->waiting_count();
$set->fuzzy_count = $set->fuzzy_count();
$set->percent_translated = $set->percent_translated();
$set->all_count = $set->all_count();
$set->wp_locale = $locale->wp_locale;
if ($this->api) {
$set->last_modified = $set->current_count ? $set->last_modified() : false;
}
}
usort($translation_sets, function ($a, $b) {
return $a->current_count < $b->current_count;
});
$translation_sets = apply_filters('gp_translation_sets_sort', $translation_sets);
$title = sprintf(__('%s project ', 'glotpress'), esc_html($project->name));
$can_write = $this->can('write', 'project', $project->id);
$this->tmpl('project', get_defined_vars());
}
开发者ID:akirk,项目名称:GlotPress,代码行数:30,代码来源:project.php
示例3: bulk_translate
public function bulk_translate($project_path)
{
$project_path = urldecode($project_path);
$url = gp_url_project($project_path);
// If we don't have rights, just redirect back to the project.
if (!GP::$user->current()->can('write', 'project')) {
gp_redirect($url);
}
// Create a project class to use to get the project object.
$project_class = new GP_Project();
// Get the project object from the project path that was passed in.
$project_obj = $project_class->by_path($project_path);
// Get the translations sets from the project ID.
$translation_sets = GP::$translation_set->by_project_id($project_obj->id);
// Loop through all the sets.
foreach ($translation_sets as $set) {
//Array ( [action] => gtranslate [priority] => 0 [redirect_to] => http://localhost/wp40/gp/projects/sample/bg/my [row-ids] => Array ( [0] => 1 [1] => 2 ) )
$bulk = array('action' => 'gtranslate', 'priority' => 0, 'row-ids' => array());
$translation = new GP_Translation();
$strings = $translation->for_translation($project_obj, $set, null, array('status' => 'untranslated'));
foreach ($strings as $string) {
$bulk['row-ids'][] .= $string->row_id;
}
$locale = GP_Locales::by_slug($set->locale);
$this->gp_translation_set_bulk_action_post($project_obj, $locale, $set, $bulk);
}
$url = gp_url_project($project_path);
gp_redirect($url);
}
开发者ID:Tucev,项目名称:Glot-O-Matic,代码行数:29,代码来源:google-translate.php
示例4: test_locale_factory_create
function test_locale_factory_create()
{
$locale_factory = new GP_UnitTest_Factory_For_Locale();
$locale = $locale_factory->create();
$this->assertEquals('aa', $locale->slug);
$this->assertEquals('Locale 1', $locale->english_name);
$this->assertSame($locale, GP_Locales::by_slug($locale->slug));
}
开发者ID:pedro-mendonca,项目名称:GlotPress-WP,代码行数:8,代码来源:test_default_factories.php
示例5: setUp
function setUp()
{
$this->is_baba = create_function('$o, $t, $l', 'return $t == "баба"? true : "error";');
$this->is_equal = create_function('$o, $t, $l', 'return $t == $o? true : "error";');
$this->w = new GP_Translation_Warnings();
$this->with_equal = new GP_Translation_Warnings();
$this->with_equal->add('is_equal', $this->is_equal);
$this->standard_plural_locale = GP_Locales::by_slug('bg');
}
开发者ID:rmccue,项目名称:GlotPress,代码行数:9,代码来源:test_warnings.php
示例6: routes
function routes()
{
$dir = '([^/]+)';
$path = '(.+?)';
$projects = 'projects';
$project = $projects . '/' . $path;
$locale = '(' . implode('|', array_map(create_function('$x', 'return $x->slug;'), GP_Locales::locales())) . ')';
// overall structure
return apply_filters('routes', array('/' => array('GP_Route_Index', 'index'), 'get:/login' => array('GP_Route_Login', 'login_get'), 'post:/login' => array('GP_Route_Login', 'login_post'), 'get:/logout' => array('GP_Route_Login', 'logout'), "get:/{$project}/import-originals" => array('GP_Route_Project', 'import_originals_get'), "post:/{$project}/import-originals" => array('GP_Route_Project', 'import_originals_post'), "get:/{$project}/_edit" => array('GP_Route_Project', 'edit_get'), "post:/{$project}/_edit" => array('GP_Route_Project', 'edit_post'), "get:/{$project}/_delete" => array('GP_Route_Project', 'delete_get'), "post:/{$project}/_delete" => array('GP_Route_Project', 'delete_post'), "post:/{$project}/_personal" => array('GP_Route_Project', 'personal_options_post'), "get:/{$projects}" => array('GP_Route_Project', 'index'), "get:/{$projects}/_new" => array('GP_Route_Project', 'new_get'), "get:/{$projects}/_new" => array('GP_Route_Project', 'new_get'), "post:/{$projects}/_new" => array('GP_Route_Project', 'new_post'), "post:/{$project}/{$locale}/{$dir}/_approve" => array('GP_Route_Translation', 'approve_post'), "get:/{$project}/{$locale}/{$dir}" => array('GP_Route_Translation', 'translations_get'), "post:/{$project}/{$locale}/{$dir}" => array('GP_Route_Translation', 'translations_post'), "get:/{$project}/{$locale}/{$dir}/import-translations" => array('GP_Route_Translation', 'import_translations_get'), "post:/{$project}/{$locale}/{$dir}/import-translations" => array('GP_Route_Translation', 'import_translations_post'), "get:/{$project}/{$locale}/{$dir}/_permissions" => array('GP_Route_Translation', 'permissions_get'), "post:/{$project}/{$locale}/{$dir}/_permissions" => array('GP_Route_Translation', 'permissions_post'), "get:/{$project}/{$locale}/{$dir}/_permissions/_delete/{$dir}" => array('GP_Route_Translation', 'permissions_delete'), "post:/{$project}/{$locale}/{$dir}/_discard-warning" => array('GP_Route_Translation', 'discard_warning'), "/{$project}/{$locale}/{$dir}/export-translations" => array('GP_Route_Translation', 'export_translations_get'), "/{$project}" => array('GP_Route_Project', 'single'), "get:/sets/_new" => array('GP_Route_Translation_Set', 'new_get'), "post:/sets/_new" => array('GP_Route_Translation_Set', 'new_post')));
}
开发者ID:rmccue,项目名称:GlotPress,代码行数:10,代码来源:routes.php
示例7: edit_get
function edit_get($glossary_id)
{
$glossary = GP::$glossary->get($glossary_id);
if (!$glossary) {
$this->redirect_with_error(__('Cannot find glossary.'));
}
$translation_set = GP::$translation_set->get($glossary->translation_set_id);
$locale = GP_Locales::by_slug($translation_set->locale);
$project = GP::$project->get($translation_set->project_id);
$this->tmpl('glossary-edit', get_defined_vars());
}
开发者ID:pedro-mendonca,项目名称:GlotPress-WP,代码行数:11,代码来源:glossary.php
示例8: new_get
function new_get()
{
$set = new GP_Translation_Set();
$set->project_id = gp_get('project_id');
if ($set->project_id) {
$this->can_or_redirect('write', 'project', $set->project_id, gp_url_project(GP::$project->get($set->project_id)));
}
$all_project_options = self::_options_from_projects(GP::$project->all());
$all_locale_options = self::_options_from_locales(GP_Locales::locales());
gp_tmpl_load('translation-set-new', get_defined_vars());
}
开发者ID:rmccue,项目名称:GlotPress,代码行数:11,代码来源:translation-set.php
示例9: locales_known
private function locales_known($user)
{
global $wpdb;
$translations = GP::$translation_set->many_no_map("\n\t\t\tSELECT ts.locale, count(*) AS count\n\t\t\tFROM {$wpdb->gp_translations} as t\n\t\t\tINNER JOIN {$wpdb->gp_translation_sets} AS ts ON ts.id = t.translation_set_id\n\t\t\tWHERE user_id = %s\n\t\t\tGROUP BY ts.locale\n\t\t\tORDER BY count DESC\n\t\t", $user->ID);
$locales = array();
foreach ($translations as $data) {
$locale = GP_Locales::by_slug($data->locale);
$locales[$locale->english_name] = array('locale' => $data->locale, 'count' => (int) $data->count);
}
return $locales;
}
开发者ID:akirk,项目名称:GlotPress,代码行数:11,代码来源:profile.php
示例10: import
function import($translations)
{
$this->set_memory_limit('256M');
if (!isset($this->project) || !$this->project) {
$this->project = GP::$project->get($this->project_id);
}
$locale = GP_Locales::by_slug($this->locale);
$user = wp_get_current_user();
$current_translations_list = GP::$translation->for_translation($this->project, $this, 'no-limit', array('status' => 'current', 'translated' => 'yes'));
$current_translations = new Translations();
foreach ($current_translations_list as $entry) {
$current_translations->add_entry($entry);
}
unset($current_translations_list);
$translations_added = 0;
foreach ($translations->entries as $entry) {
if (empty($entry->translations)) {
continue;
}
$is_fuzzy = in_array('fuzzy', $entry->flags);
if ($is_fuzzy && !apply_filters('gp_translation_set_import_fuzzy_translations', true, $entry, $translations)) {
continue;
}
$create = false;
if ($translated = $current_translations->translate_entry($entry)) {
// we have the same string translated
// create a new one if they don't match
$entry->original_id = $translated->original_id;
$translated_is_different = array_pad($entry->translations, $locale->nplurals, null) != $translated->translations;
$create = apply_filters('gp_translation_set_import_over_existing', $translated_is_different);
} else {
// we don't have the string translated, let's see if the original is there
$original = GP::$original->by_project_id_and_entry($this->project->id, $entry, '+active');
if ($original) {
$entry->original_id = $original->id;
$create = true;
}
}
if ($create) {
if ($user) {
$entry->user_id = $user->ID;
}
$entry->translation_set_id = $this->id;
$entry->status = apply_filters('gp_translation_set_import_status', $is_fuzzy ? 'fuzzy' : 'current');
// check for errors
$translation = GP::$translation->create($entry);
$translation->set_status($entry->status);
$translations_added += 1;
}
}
gp_clean_translation_set_cache($this->id);
do_action('gp_translations_imported', $this->id);
return $translations_added;
}
开发者ID:akirk,项目名称:GlotPress,代码行数:54,代码来源:translation-set.php
示例11: default_routes
private function default_routes()
{
$dir = '([^_/][^/]*)';
$path = '(.+?)';
$projects = 'projects';
$project = $projects . '/' . $path;
$id = '(\\d+)';
$locale = '(' . implode('|', wp_list_pluck(GP_Locales::locales(), 'slug')) . ')';
$set = "{$project}/{$locale}/{$dir}";
// overall structure
return array('/' => array('GP_Route_Index', 'index'), 'get:/profile' => array('GP_Route_Profile', 'profile_get'), "get:/profile/{$path}" => array('GP_Route_Profile', 'profile_view'), 'post:/profile' => array('GP_Route_Profile', 'profile_post'), 'get:/languages' => array('GP_Route_Locale', 'locales_get'), "get:/languages/{$locale}/{$path}" => array('GP_Route_Locale', 'single'), "get:/languages/{$locale}" => array('GP_Route_Locale', 'single'), "get:/{$set}/glossary" => array('GP_Route_Glossary_Entry', 'glossary_entries_get'), "post:/{$set}/glossary" => array('GP_Route_Glossary_Entry', 'glossary_entries_post'), "post:/{$set}/glossary/-new" => array('GP_Route_Glossary_Entry', 'glossary_entry_add_post'), "post:/{$set}/glossary/-delete" => array('GP_Route_Glossary_Entry', 'glossary_entry_delete_post'), "get:/{$set}/glossary/-export" => array('GP_Route_Glossary_Entry', 'export_glossary_entries_get'), "get:/{$set}/glossary/-import" => array('GP_Route_Glossary_Entry', 'import_glossary_entries_get'), "post:/{$set}/glossary/-import" => array('GP_Route_Glossary_Entry', 'import_glossary_entries_post'), "get:/{$project}/import-originals" => array('GP_Route_Project', 'import_originals_get'), "post:/{$project}/import-originals" => array('GP_Route_Project', 'import_originals_post'), "get:/{$project}/-edit" => array('GP_Route_Project', 'edit_get'), "post:/{$project}/-edit" => array('GP_Route_Project', 'edit_post'), "post:/{$project}/-personal" => array('GP_Route_Project', 'personal_options_post'), "get:/{$project}/-permissions" => array('GP_Route_Project', 'permissions_get'), "post:/{$project}/-permissions" => array('GP_Route_Project', 'permissions_post'), "get:/{$project}/-permissions/-delete/{$dir}" => array('GP_Route_Project', 'permissions_delete'), "get:/{$project}/-mass-create-sets" => array('GP_Route_Project', 'mass_create_sets_get'), "post:/{$project}/-mass-create-sets" => array('GP_Route_Project', 'mass_create_sets_post'), "post:/{$project}/-mass-create-sets/preview" => array('GP_Route_Project', 'mass_create_sets_preview_post'), "get:/{$project}/-branch" => array('GP_Route_Project', 'branch_project_get'), "post:/{$project}/-branch" => array('GP_Route_Project', 'branch_project_post'), "get:/{$projects}" => array('GP_Route_Project', 'index'), "get:/{$projects}/-new" => array('GP_Route_Project', 'new_get'), "post:/{$projects}/-new" => array('GP_Route_Project', 'new_post'), "post:/{$set}/-bulk" => array('GP_Route_Translation', 'bulk_post'), "get:/{$set}/import-translations" => array('GP_Route_Translation', 'import_translations_get'), "post:/{$set}/import-translations" => array('GP_Route_Translation', 'import_translations_post'), "post:/{$set}/-discard-warning" => array('GP_Route_Translation', 'discard_warning'), "post:/{$set}/-set-status" => array('GP_Route_Translation', 'set_status'), "/{$set}/export-translations" => array('GP_Route_Translation', 'export_translations_get'), "get:/{$set}" => array('GP_Route_Translation', 'translations_get'), "post:/{$set}" => array('GP_Route_Translation', 'translations_post'), "/{$project}" => array('GP_Route_Project', 'single'), "get:/sets/-new" => array('GP_Route_Translation_Set', 'new_get'), "post:/sets/-new" => array('GP_Route_Translation_Set', 'new_post'), "get:/sets/{$id}" => array('GP_Route_Translation_Set', 'single'), "get:/sets/{$id}/-edit" => array('GP_Route_Translation_Set', 'edit_get'), "post:/sets/{$id}/-edit" => array('GP_Route_Translation_Set', 'edit_post'), "get:/glossaries/-new" => array('GP_Route_Glossary', 'new_get'), "post:/glossaries/-new" => array('GP_Route_Glossary', 'new_post'), "get:/glossaries/{$id}/-edit" => array('GP_Route_Glossary', 'edit_get'), "post:/glossaries/{$id}/-edit" => array('GP_Route_Glossary', 'edit_post'), "post:/originals/{$id}/set_priority" => array('GP_Route_Original', 'set_priority'));
}
开发者ID:johnjamesjacoby,项目名称:GlotPress-WP,代码行数:12,代码来源:router.php
示例12: clean_up_global_scope
function clean_up_global_scope()
{
parent::clean_up_global_scope();
$locales =& GP_Locales::instance();
$locales->locales = array();
$_GET = array();
$_POST = array();
/**
* @todo re-initialize all thing objects
*/
GP::$translation_set = new GP_Translation_Set();
GP::$original = new GP_Original();
}
开发者ID:akirk,项目名称:GlotPress,代码行数:13,代码来源:testcase.php
示例13: action_on_translation_set
function action_on_translation_set($translation_set)
{
$project = GP::$project->get($translation_set->project_id);
$locale = GP_Locales::by_slug($translation_set->locale);
foreach (GP::$translation->for_translation($project, $translation_set, 'no-limit') as $entry) {
$warnings = GP::$translation_warnings->check($entry->singular, $entry->plural, $entry->translations, $locale);
if ($warnings != $entry->warnings) {
$translation = new GP_Translation(array('id' => $entry->id));
echo sprintf(__("Updating warnings for %s"), $entry->id) . "\n";
$translation->update(array('warnings' => $warnings));
}
}
}
开发者ID:pedro-mendonca,项目名称:GlotPress-WP,代码行数:13,代码来源:recheck-warnings.php
示例14: clean_up_global_scope
function clean_up_global_scope()
{
GP::$user->reintialize_wp_users_object();
$locales =& GP_Locales::instance();
$locales->locales = array();
$_GET = array();
$_POST = array();
$this->flush_cache();
/**
* @todo re-initialize all thing objects
*/
GP::$translation_set = new GP_Translation_Set();
GP::$original = new GP_Original();
}
开发者ID:rmccue,项目名称:glotpress-plugin,代码行数:14,代码来源:testcase.php
示例15: __invoke
/**
* Get the slug from a WPorg slug
*
* ## OPTIONS
*
* <wporg-locale>
* : WP.org locale slug
*/
public function __invoke($args)
{
$wporg_slug = $args[0];
$slug = null;
foreach (GP_Locales::locales() as $locale) {
if ($locale->wp_locale == $wporg_slug) {
$slug = $locale->slug;
break;
}
}
if (!$slug) {
WP_CLI::error(sprintf(__('No slug match for %s.', 'glotpress'), $wporg_slug));
}
WP_CLI::line($slug);
}
开发者ID:akirk,项目名称:GlotPress,代码行数:23,代码来源:wporg2slug.php
示例16: import
function import($translations)
{
@ini_set('memory_limit', '256M');
if (!isset($this->project) || !$this->project) {
$this->project = GP::$project->get($this->project_id);
}
$locale = GP_Locales::by_slug($this->locale);
$current_translations_list = GP::$translation->for_translation($this->project, $this, 'no-limit', array('status' => 'current', 'translated' => 'yes'));
$current_translations = new Translations();
foreach ($current_translations_list as $entry) {
$current_translations->add_entry($entry);
}
unset($current_translations_list);
$translations_added = 0;
foreach ($translations->entries as $entry) {
if (empty($entry->translations)) {
continue;
}
if (in_array('fuzzy', $entry->flags)) {
continue;
}
$create = false;
if ($translated = $current_translations->translate_entry($entry)) {
// we have the same string translated
// create a new one if they don't match
$entry->original_id = $translated->original_id;
$create = array_pad($entry->translations, $locale->nplurals, null) != $translated->translations;
} else {
// we don't have the string translated, let's see if the original is there
$original = GP::$original->by_project_id_and_entry($this->project->id, $entry);
if ($original) {
$entry->original_id = $original->id;
$create = true;
}
}
if ($create) {
$entry->translation_set_id = $this->id;
$entry->status = 'current';
// check for errors
$translation = GP::$translation->create($entry);
$translation->set_as_current();
$translations_added += 1;
}
}
wp_cache_delete($this->id, 'translation_set_status_breakdown');
return $translations_added;
}
开发者ID:rmccue,项目名称:GlotPress,代码行数:47,代码来源:translation-set.php
示例17: run
function run()
{
if (!isset($this->args[0])) {
$this->usage();
}
$wporg_slug = $this->args[0];
$slug = null;
foreach (GP_Locales::locales() as $locale) {
if ($locale->wp_locale == $wporg_slug) {
$slug = $locale->slug;
break;
}
}
if (!$slug) {
$this->to_stderr("No slug match for {$wporg_slug}.");
} else {
echo $slug;
}
}
开发者ID:pedro-mendonca,项目名称:GlotPress-WP,代码行数:19,代码来源:wporg2slug.php
示例18: run
public function run()
{
if (!isset($this->options['l']) || !isset($this->options['p'])) {
$this->usage();
}
$this->project = GP::$project->by_path($this->options['p']);
if (!$this->project) {
$this->error(__('Project not found!', 'glotpress'));
}
$this->locale = GP_Locales::by_slug($this->options['l']);
if (!$this->locale) {
$this->error(__('Locale not found!', 'glotpress'));
}
$this->options['t'] = gp_array_get($this->options, 't', 'default');
$this->translation_set = GP::$translation_set->by_project_id_slug_and_locale($this->project->id, $this->options['t'], $this->locale->slug);
if (!$this->translation_set) {
$this->error(__('Translation set not found!', 'glotpress'));
}
$this->action_on_translation_set($this->translation_set);
}
开发者ID:ramiy,项目名称:GlotPress-WP,代码行数:20,代码来源:cli.php
示例19: single
public function single($project_path)
{
$project = GP::$project->by_path($project_path);
if (!$project) {
return $this->die_with_404();
}
$sub_projects = $project->sub_projects();
$translation_sets = GP::$translation_set->by_project_id($project->id);
foreach ($translation_sets as $set) {
$locale = GP_Locales::by_slug($set->locale);
$set->name_with_locale = $set->name_with_locale();
$set->current_count = $set->current_count();
$set->untranslated_count = $set->untranslated_count();
$set->waiting_count = $set->waiting_count();
$set->fuzzy_count = $set->fuzzy_count();
$set->percent_translated = $set->percent_translated();
$set->all_count = $set->all_count();
$set->wp_locale = $locale->wp_locale;
if ($this->api) {
$set->last_modified = $set->current_count ? $set->last_modified() : false;
}
}
usort($translation_sets, function ($a, $b) {
return $a->current_count < $b->current_count;
});
/**
* Filter the list of translation sets of a project.
*
* Can also be used to sort the sets to a custom order.
*
* @since 1.0.0
*
* @param GP_Translation_Sets[] $translation_sets An array of translation sets.
*/
$translation_sets = apply_filters('gp_translation_sets_sort', $translation_sets);
$title = sprintf(__('%s project ', 'glotpress'), esc_html($project->name));
$can_write = $this->can('write', 'project', $project->id);
$this->tmpl('project', get_defined_vars());
}
开发者ID:chantalcoolsma,项目名称:GlotPress-WP,代码行数:39,代码来源:project.php
示例20: get_cap_key
function get_cap_key($locale_slug)
{
global $gpdb;
static $ros_blogs, $ros_locale_assoc;
$gp_locale = GP_Locales::by_slug($locale_slug);
if (!$gp_locale || !isset($gp_locale->wp_locale)) {
return false;
}
$wp_locale = $gp_locale->wp_locale;
if (!isset($ros_blogs)) {
$ros_locale_assoc = $gpdb->get_results("SELECT locale, subdomain FROM locales", OBJECT_K);
$ros_blogs = $gpdb->get_results("SELECT domain, blog_id FROM ros_blogs", OBJECT_K);
}
if (isset($ros_locale_assoc[$wp_locale])) {
$subdomain = $ros_locale_assoc[$wp_locale]->subdomain;
} else {
return false;
}
if (isset($ros_blogs["{$subdomain}.wordpress.org"])) {
return 'ros_' . $ros_blogs["{$subdomain}.wordpress.org"]->blog_id . '_capabilities';
}
return false;
}
开发者ID:serhi,项目名称:wordpress-sites,代码行数:23,代码来源:wporg-rosetta-roles.php
注:本文中的GP_Locales类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论