All Projects → crowdin → crowdin-api-client-ruby

crowdin / crowdin-api-client-ruby

Licence: MIT license
The Crowdin Ruby Client is used to interact with the Crowdin API v2 from Ruby

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to crowdin-api-client-ruby

i18n-core
i18n-core is a no-fuzz Node.js implementation of i18n.
Stars: ✭ 14 (-72%)
Mutual labels:  i18n
go-localize
i18n (Internationalization and localization) engine written in Go, used for translating locale strings.
Stars: ✭ 45 (-10%)
Mutual labels:  i18n
mini i18n
🌐 Minimalistic I18n library for Ruby
Stars: ✭ 93 (+86%)
Mutual labels:  i18n
background-translation-i18n
Based on the YII2 module to translate JSON formatted translation files on the web
Stars: ✭ 11 (-78%)
Mutual labels:  i18n
advanced-spring-scaffold
This project provides an advanced baseline to help you kick start a Spring project.
Stars: ✭ 21 (-58%)
Mutual labels:  i18n
odoo-th
Ready to use Odoo with OCA Thai localization modules
Stars: ✭ 29 (-42%)
Mutual labels:  i18n
enumize
Extend ActiveRecord::Enum for add more helpful methods.
Stars: ✭ 25 (-50%)
Mutual labels:  i18n
LorittaLocales
🌎 Loritta's localization files, bringing Loritta's cuteness to everyone around the world!
Stars: ✭ 21 (-58%)
Mutual labels:  i18n
fyodor
Convert your Amazon Kindle highlights and notes into markdown (or any format).
Stars: ✭ 101 (+102%)
Mutual labels:  i18n
pH7-Internationalization
🎌 pH7CMS Internationalization (I18N) package 🙊 Get new languages for your pH7CMS website!
Stars: ✭ 17 (-66%)
Mutual labels:  i18n
ra-language-japanese
Japanese messages for react-admin
Stars: ✭ 22 (-56%)
Mutual labels:  i18n
D-i18n
前端国际化通用解决方案。抹平不同前端开发技术栈所带来的差异。
Stars: ✭ 85 (+70%)
Mutual labels:  i18n
Domino-English-Translation
🌏 Let's translate Domino, a Japanese MIDI editor!
Stars: ✭ 29 (-42%)
Mutual labels:  i18n
li18nt
🌎 Lint your i18n translation files. Detect conflicting properties, duplicates and make it more readable and easier to maintain by formatting it!
Stars: ✭ 29 (-42%)
Mutual labels:  i18n
grav-plugin-langswitcher
Grav LangSwitcher Plugin
Stars: ✭ 22 (-56%)
Mutual labels:  i18n
next
(Work in progress) The rewritten version of the original PizzaQL 🍕
Stars: ✭ 45 (-10%)
Mutual labels:  i18n
elm-format-number
✨Format numbers as pretty strings
Stars: ✭ 56 (+12%)
Mutual labels:  i18n
vue-example
Vue.js example application (server-side rendering, router, vuex store, form validation, i18n & l10n)
Stars: ✭ 62 (+24%)
Mutual labels:  i18n
awesome-translations
😎 Awesome lists about Internationalization & localization stuff. l10n, g11n, m17n, i18n. Translations! 🌎🌍
Stars: ✭ 54 (+8%)
Mutual labels:  i18n
markdown-i18n
i18n extension for Python Markdown
Stars: ✭ 13 (-74%)
Mutual labels:  i18n

Crowdin Ruby client

The Crowdin Ruby client is a lightweight interface to the Crowdin API v2. It provides common services for making API requests.

Crowdin API is a full-featured RESTful API that helps you to integrate localization into your development process. The endpoints that we use allow you to easily make calls to retrieve information and to execute actions needed.

Table of Contents

Requirements

  • Ruby >= 2.4

Installation

Add this line to your application's Gemfile:

gem 'crowdin-api', '~> 1.4.0'

And then execute:

bundle install

Or install it yourself as:

gem install crowdin-api

📑 For versions 0.6.0 and lower see the branch api/v1. Please note that these versions are no longer supported.

Migration from version 0.6.0 to 1.x.x requires changes in your code.


Quick start

Initialization

require 'crowdin-api'

# Initialize a new Client instance with config options
crowdin = Crowdin::Client.new do |config|
  config.api_token = 'YourApiToken'
end

# Or you can initialize Enterprise Client instance by specifying your
# organization_domain in config options
crowdin = Crowdin::Client.new do |config|
  config.api_token = 'YourEnterpriseApiToken'
  config.organization_domain = 'YourOrganizationDomain'
end
# Note: we use full specified organization domain if that includes '.com'
# config.organization_domain = your_domain -> https://your_domain.api.crowdin.com
# config.organization_domain = your_domain.com -> https://your_domain.com

# All supported Crowdin Client config options now:
crowdin = Crowdin::Client.new do |config|
  config.api_token = 'YourApiToken' # [String] required
  config.organization_domain = 'YourOrganizationDomain' # [String] optional
  config.project_id = 'YourProjectId' # [Integer] nil by default
  config.enable_logger = true # [Boolean] false by default
end
# Note: Client will initialize default Logger instance if you have specify
# enable_logger to true, you can change it by crowdin.logger = YourLogger

# Also you can specify proxy by adding it to ENV['http_proxy'] before Client initialization

To generate a new token in Crowdin, follow these steps:

  • Go to Account Settings > API tab, Personal Access Tokens section, and click New Token.
  • Specify Token Name and click Create.

To generate a new token in Crowdin Enterprise, follow these steps:

  • Go to Account Settings > Access tokens tab and click New token.
  • Specify Token Name, select Scopes and Projects, click Create.

Usage

# Create Project
project = crowdin.add_project(name: your_project_name, sourceLanguageId: your_language_id)

# Get list of Projects
projects = crowdin.list_projects

# Get list of Projects with offset and limit
projects = crowdin.list_projects(offset: 10, limit: 20)

# Get specified project
project = crowdin.get_project(your_project_id)

# Edit project
project = crowdin.edit_project(project_id, [{ op: 'replace',
                                              path: '/name',
                                              value: 'your_new_project_name' }])

# Add Storage
storage = crowdin.add_storage(File.open('YourFilename.extension', 'r'))
# or you can specify only absolute path to file
storage = crowdin.add_storage('YourFilename.extension')

# Download file
file = crowdin.download_file(your_file_id, your_destination, your_project_id)
# your_destination - filename or absolute path to file, optional
# Without destination option file will be saved to the current directory with a default filename
# project_id is optional, as it can be initialized with a Crowdin Client

# File revisions
# with initialized project_id in your Client
file_revisions = crowdin.list_file_revisions(your_file_id, limit: 10)
# or you can specify your project_id
file_revisions = crowdin.list_file_revisions(your_file_id, { limit: 10 }, your_project_id)

# Note: more examples you can find in spec folder

Fetch all records

There is a possibility to fetch all records from paginatable methods using fetch_all method.

# FetchAll options:
# * limit, Integer, default: 500 | How many records need to load per one request
# * offset, Integer, default: 0
# * request_delay, Integer (seconds), default: 0 | Delay between requests. To specify a delay in milliseconds use float values like 0.100

# Examples:

@crowdin.fetch_all(:list_projects)

# with options
@crowdin.fetch_all(:list_projects, { limit: 10, request_delay: 1 })

# playing with response per fetch
# Note: the block actually don't make any effect to finite result
@crowdin.fetch_all(:list_projects, { limit: 10, request_delay: 1 }) { |response| puts response['data'] }

# also, you could specify a retry configuration to handle some exceptions
# fetch all execution will be terminated if response status code is the same as one of the error_messages array value
# otherwise, the request will be retried so many times, as indicated at retries_count
@crowdin.fetch_all(:list_projects, {}, { request_delay: 2, retries_count: 3, error_messages: ['401'] })

Command-Line Client

The Crowdin Ruby client support crowdin-console, where you can test endpoints easier

$ bundle exec crowdin-console --enable-logger --api-token API_TOKEN --project-id PROJECT_ID

Or Crowdin Enterprise

$ bundle exec crowdin-console --enable-logger --enterprise --api-token API_TOKEN --organization-domain DOMAIN --project-id PROJECT_ID

Note: you can specify full organization domain by adding '.com'

When execute you'll have IRB console with configured @crowdin instance

> @crowdin.list_projects

Seeking Assistance

If you find any problems or would like to suggest a feature, please read the How can I contribute section in our contributing guidelines.

Need help working with Crowdin Ruby client or have any questions? Contact Customer Success Service.

Contributing

If you want to contribute please read the Contributing guidelines.

License

The Crowdin Ruby Client is licensed under the MIT License.
See the LICENSE.md file distributed with this work for additional 
information regarding copyright ownership.

Except as contained in the LICENSE file, the name(s) of the above copyright
holders shall not be used in advertising or otherwise to promote the sale,
use or other dealings in this Software without prior written authorization.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].