定制 ucraft-com/translation-app-sdk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ucraft-com/translation-app-sdk

Composer 安装命令:

composer require ucraft-com/translation-app-sdk

包简介

SDK to access translations using gRPC

README 文档

README

Introduction

Welcome to the Translation App SDK for PHP! This library provides a seamless integration with our Translation App, allowing you to easily manage translations within your PHP application. Whether you're building a multilingual website or a globalized application, this SDK simplifies the process of handling translations.

Installation

Install the Translation App SDK using Composer:

composer require ucraft-com/translation-app-sdk

QueryTranslationItemsValueObject

The QueryTranslationItemsValueObject is used for querying translation items. It holds values for specifying the resource, resource ID, language code, and additional options for querying.

Usage Example

use Uc\TranslationAppSdk\ValueObjects\QueryTranslationItemsValueObject;

// Create a QueryTranslationItemsValueObject instance
$queryObject = new QueryTranslationItemsValueObject(
    'en-US', // locale
    'your_resource', // optional, ex: project_id 
    1, // optional, ex: project id (1)
    'key', // optional, key to search
    ['key' => 'asc'], // optional, or 'updated_at' => 'desc'
    1, // optional, page number
    20, // optional, first n entites
    false, // optional, find all, default false
);

// Accessing properties
$resource = $queryObject->getResource();
$resourceId = $queryObject->getResourceId();
$languageCode = $queryObject->getLanguageCode();
$key = $queryObject->getKey();
$orderBy = $queryObject->getOrderBy();
$page = $queryObject->getPage();
$first = $queryObject->getFirst();
$findAll = $queryObject->getFindAll();

UpsertTranslationItemValueObject

The UpsertTranslationItemValueObject is used for upserting translation items. It holds values for specifying the translation value, language code, translation entry ID, resource, resource ID, editor name, and optional parameters.

Usage Example

use Uc\TranslationAppSdk\ValueObjects\UpsertTranslationItemValueObject;

// Create an UpsertTranslationItemValueObject instance
$upsertObject = new UpsertTranslationItemValueObject(
    'Hello, World!', // value
    'en-US', // locale
    'your_translation_entry_id', // translation entry id (relation)
    'John Doe', // editor name
    'your_resource', // optional, ex: project_id 
    1, // optional, ex: project id (1)
    null, // optional, translation id (when updating, when null: creating)
    ['param1' => 'value1', 'param2' => 'value2'] // optional, some params that may be used
);

// Accessing properties
$resource = $upsertObject->getResource();
$resourceId = $upsertObject->getResourceId();
$key = $upsertObject->getKey();
$editorName = $upsertObject->getEditorName();
$value = $upsertObject->getValue();
$languageCode = $upsertObject->getLanguageCode();
$hasTranslationId = $upsertObject->hasTranslationId();
$translationId = $upsertObject->getTranslationId();
$hasParams = $upsertObject->hasParams();
$params = $upsertObject->getParams();

TranslationAppClient

The TranslationAppClient is a client class that allows you to interact with RPC methods for managing translations.

Usage Example

use Uc\TranslationAppSdk\TranslationAppClient;
use Uc\TranslationAppSdk\ValueObjects\UpsertTranslationItemValueObject;
use Uc\TranslationAppSdk\ValueObjects\QueryTranslationItemsValueObject;

// Create a TranslationAppClient instance
$client = new TranslationAppClient($yourTranslationClientInstance);

// Example QueryTranslationItemsValueObject
$queryObject = new QueryTranslationItemsValueObject(
    'en-US',
    'your_resource',
    1,
    'key',
    ['key' => 'asc'],
    1,
    20,
    false,
);

// Example UpsertTranslationItemValueObject
$upsertObject = new UpsertTranslationItemValueObject(
    'Hello, World!',
    'en-US',
    'your_translation_entry_id',
    'John Doe',
    'your_resource', 
    1, 
    null, 
    ['param1' => 'value1', 'param2' => 'value2'] 
);

// Get paginated translations
$paginatedTranslations = $client->getTranslations($queryObject);

// Find all translations without pagination
$allTranslations = $client->findAll($queryObject);

// Upsert a translation item
$upsertedTranslation = $client->upsert($upsertObject);

License

The Translation App SDK for PHP is open-source software licensed under the MIT License.

ucraft-com/translation-app-sdk 适用场景与选型建议

ucraft-com/translation-app-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.52k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 09 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 ucraft-com/translation-app-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ucraft-com/translation-app-sdk 我们能提供哪些服务?
定制开发 / 二次开发

基于 ucraft-com/translation-app-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3.52k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 8
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 6
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-09-07