Git Product home page Git Product logo

webtranslateit's Introduction

WebTranslateIt Synchronization Tool : wti

RubyDoc | Report a bug | Support | WebTranslateIt.com Homepage | Docker Package

wti lets you easily sync your language files with WebTranslateIt.com, a web-based tool to translation software.

WebTranslateIt Synchronization Tool

wti...

  • wti is a command-line tool. It works on all operating systems: Windows, Linux, MacOS X, ... It is also available as a Docker package.
  • wti is really easy to use. It was inspired by git. Use wti push and wti pull to sync your language files with WebTranslateIt.com.

Optionally, wti does...

  • include a rack middleware you can use in your Rails app to automatically fetch new translations from WebTranslateIt.com.
  • include libraries you can use to programmatically fetch your segments from WebTranslateIt.com. See Extras
  • include a web interface for your translation team to update your language files. Learn more on the web_translate_it_server project page.

Installation

You will also need ruby to run wti. We require ruby version 2.6 or newer. On Linux or a Mac, it’s already installed. Install RubyInstaller if you’re using Windows. See detailed installation instructions for Windows users.

$ gem install web_translate_it
Fetching: web_translate_it-2.6.4.gem (100%)
Successfully installed web_translate_it-2.6.4
1 gem installed

At this point you should have the wti executable working:

$ wti -v
wti version 2.6.4

We also provide wti as a Docker packages. See our packages and instructions to install.

Configuration

Now that wti is installed, you’ll have to configure your project. Basically, wti is to be run on a project root directory, and looks for a .wti file containing your project information. The command wti init lets your create your .wti file.

$ wti init proj_pvt_V8skdjsdDDA4
# Initializing project

 The project Frontend was successfully initialized.

You can now use `wti` to push and pull your language files.
Check `wti --help` for help.

proj_pvt_V8skdjsdDDA4 is the API token, which you can find in your project settings.

If you’d like to specify another path for your configuration file, you can use wti init. This command will ask you to enter your project API token and where to save the configuration file (by default it will create a .wti in your project root directory).

Now you’re all set and you can use the wti commands on your project.

Using on multiple projects

Please refer to our documentation about syncing multiple projects.

Usage

Execute wti --help to see the usage:

Usage: wti <command> [options]+

The most commonly used wti commands are:

  pull        Pull target language file(s)
  push        Push master language file(s)
  match       Display matching of local files with File Manager
  add         Create and push a new master language file
  addlocale   Add a new locale to the project
  server      Start a synchronisation server
  status      Fetch and display project statistics
  init        Configure your project to sync      

See `wti <command> --help` for more information on a specific command.

[options] are:
  --config, -c <s>:   Path to a translation.yml file (default: .wti)
     --version, -v:   Print version and exit
        --help, -h:   Show this message

Append --help for each command for more information. For instance:

$ wti push --help
wti push [filename] - Push master language file(s)
[options] are:
  -l, --locale=<s>        ISO code of locale(s) to push
  -t, --target            Upload all target files
  -f, --force             Force push (bypass conditional requests to WTI)
  -m, --merge             Force WTI to merge this file
  -i, --ignore-missing    Force WTI to not obsolete missing strings
  -n, --minor             Minor Changes. When pushing a master file, prevents
                          target translations to be flagged as `to_verify`.
  -a, --label=<s>         Apply a label to the changes
  -c, --config=<s>        Path to a configuration file (default: .wti)
  --all                   DEPRECATED -- See `wti push --target` instead
  -d, --debug             Display debug information
  -h, --help              Show this message

Sample Commands

Command Action
wti add path/to/master/file.po Upload a new master language file
wti add file1.po file2.po file3.xml Create several master language files at once, by specifying each file
wti add *.po Create several master language files at once, by specifying an extension
find . -name "*en.yml" | xargs wti add Find all the en.yml files and add them to the project
wti push Update a master language file
wti push -l fr Update a target (French) language file
wti push -l "fr en da sv" Update several target language files at once (French, English, Danish, Swedish)
wti push --all Update all language files at once
wti push path/to/file.yml Pushes the path/to/file.yml file
wti pull Download target language files
wti pull -l fr Download a specific language file (French)
wti pull --all Download all language files, including source
wti pull path/to/files/* Download all files in path/to/files
wti pull path/to/files/* -l fr Download all fr files in path/to/files
wti pull --force Force pull (to bypass WebTranslateIt’s HTTP caching)
wti addlocale fr Add a new locale to the project
wti addlocale fr da sv Add several locales at once
wti status View project translation statistics
wti status config/locales/app/en.yml View translation statistics on file config/locales/app/en.yml
wti match Show matching between files on local computer and the ones in WebTranslateIt’s File Manager

Hooks

It is sometimes useful to hook a command or a script before or after a push or a pull. One use-case would be to launch a build after pulling language files. You can do that by implementing hooks in your .wti file.

There are 4 hooks:

  • before_pull
  • after_pull
  • before_push
  • after_push

Check the sample .wti file for implementation.

Exit codes

wti returns exit codes on failure. The exit code is 0 if the command executed successfully and 1 if the command executed but encountered at least one error. This is useful to act upon errors if you use wti to pull files in an automated build process.

~/code/webtranslateit.com[master]% wti pull
# Pulling files on WebTranslateIt
 config/locales/translation_validator/en.yml        | e82e044..e82e044  Skipped
 config/locales/app/en.yml                          | f2ca86c..f2ca86c  Skipped
 config/locales/defaults/en.yml                     | 2fcb61f..2fcb61f  Skipped
 config/locales/js/en.yml                           | ee6589d..ee6589d  Skipped
 config/locales/js/fr.yml                           | 2f8bb0e..2f8bb0e  Skipped
 config/locales/translation_validator/fr.yml        | 534af2c..534af2c  Skipped
 config/locales/app/fr.yml                          | 29f8c9d..da39a3e  OK
 config/locales/defaults/fr.yml                     | aca123e..aca123e  Skipped
Pulled 8 files at 7 files/sec, using 3 threads.

~/code/webtranslateit.com[master]% echo $?
0

~/code/webtranslateit.com[master]% wti pull
# Pulling files on WebTranslateIt
 config/locales/translation_validator/en.yml        | e82e044..e82e044  Error
 config/locales/app/en.yml                          | f2ca86c..f2ca86c  Skipped
 config/locales/defaults/fr.yml                     | aca123e..aca123e  Skipped
Pulled 3 files at 3 files/sec, using 3 threads.

~/code/webtranslateit.com[master]% echo $?
1

wti status command also returns meaningful codes. It will exit with 0 if the project is 100% translated and proofread, 100 if the project is not 100% translated and 101 if the project is not 100% proofread. This could allow you to check if a project is 100% translated or completed before deploying a project.

~/Desktop/test% wti status
# Gathering information on test ts
fr: 40% translated, 40% completed.
en: 90% translated, 0% completed.

~/Desktop/test% echo $?
100

~/Desktop/test% wti status
# Gathering information on test ts
en: 100% translated, 0% completed.
fr: 100% translated, 100% completed.

~/Desktop/test% echo $?
101

~/Desktop/test% wti status
# Gathering information on test ts
en: 100% translated, 100% completed.
fr: 100% translated, 100% completed.

~/Desktop/test% echo $?   
0

License

Copyright (c) 2009-2023 WebTranslateIt Software S.L, released under the MIT License.

webtranslateit's People

Contributors

benedikt avatar bray avatar dependabot[bot] avatar edhgoose avatar edouard avatar felixclack avatar icrowley avatar jamesbebbington avatar joao-pacheco-blip avatar jukra avatar matiaskorhonen avatar mikian avatar olleolleolle avatar philippb avatar qwzybug avatar rogerluan avatar rsempe avatar schorsch avatar vicv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webtranslateit's Issues

Executable

Create an executable that basically do the same job than the rake tasks, so it can be used by more programming languages.

Notify the user of a new version of the plugin

rake trans:version could check http://github.com/api/v2/yaml/repos/show/atelierconvivialite/webtranslateit/tags and tell the user if her plugin is out of date.

$ rake trans:version

Web Translate It plugin for Ruby on Rails
Should you need help, please visit:
* https://webtranslateit.com/help
* https://webtranslateit.com/forum

Web Translate It plugin for Ruby on Rails v1.2.1
A new version 1.2.2 is available. Install it with ruby script/plugin install [email protected]:AtelierConvivialite/webtranslateit.git --force
or go and check the changes: http://github.com/AtelierConvivialite/webtranslateit

Two errors when running specs

NoMethodError in 'WebTranslateIt::TranslationFile#fetch should prepare a HTTP request and get a 200 OK if the language file is stale' undefined method `>=' for nil:NilClass
translation_file.rb:38:in `fetch'
translation_file_spec.rb:21:

Better commands

wti push should only push the source language file. Have a wti push --all to push all, and keep wti push -l [locale] to only push a locale.

Same goes for wti pull, should only pull target language files. wti pull --all to pull all.

Allow use of underscored locales

The ruby client doesn't support option like -l fr_FR.
Even if you have configure undercore in the project, you still need to use -l fr-FR.

undefined method 'blank?' raised on Strings

Hey Édouard,

Following on from our chat in tender I've installed v1.6.2 of the gem and attempted to integrated my app with wti from scratch again. I'm still not having much luck though:

$ wti autoconf
We will attempt to configure your project automagically
Please enter your project API Key:
7919<snip>12f2c
Where should we create the configuration file? (Default: `config/translation.yml`)

/Library/Ruby/Gems/1.8/gems/web_translate_it-1.6.2/lib/web_translate_it/command_line.rb:83:in `autoconf': undefined method `blank?' for "config/locales/models/schedulable.en.yml":String (NoMethodError)
    from /Library/Ruby/Gems/1.8/gems/web_translate_it-1.6.2/lib/web_translate_it/command_line.rb:82:in `each'
    from /Library/Ruby/Gems/1.8/gems/web_translate_it-1.6.2/lib/web_translate_it/command_line.rb:82:in `autoconf'
    from /Library/Ruby/Gems/1.8/gems/web_translate_it-1.6.2/lib/web_translate_it/command_line.rb:33:in `run'
    from /Library/Ruby/Gems/1.8/gems/web_translate_it-1.6.2/bin/wti:5
    from /usr/bin/wti:19:in `load'
    from /usr/bin/wti:19

This works however:

$ script/generate webtranslateit --api-key 7919<snip>12f2c
./script/../config/../vendor/rails/railties/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010.  Use #requirement
<rails_root>/vendor/gems/thoughtbot-paperclip-2.3.1/lib/paperclip.rb:47: warning: already initialized constant VERSION
** Erubis 2.6.5
      create  config/translation.yml
      insert  require 'web_translate_it/tasks' rescue LoadError appended to Rakefile
Loaded suite script/generate
Started

Finished in 0.000448 seconds.

0 tests, 0 assertions, 0 failures, 0 errors

I'm not sure why there's some kinda test output there, I don't think that's to do with wti though, something else is playing up I think.

Attempting to push results in a similar error:

$ wti push
/Library/Ruby/Gems/1.8/gems/web_translate_it-1.6.2/lib/web_translate_it/configuration.rb:44:in `set_files': undefined method `blank?' for "config/locales/models/schedulable.en.yml":String (NoMethodError)
    from /Library/Ruby/Gems/1.8/gems/web_translate_it-1.6.2/lib/web_translate_it/configuration.rb:43:in `each'
    from /Library/Ruby/Gems/1.8/gems/web_translate_it-1.6.2/lib/web_translate_it/configuration.rb:43:in `set_files'
    from /Library/Ruby/Gems/1.8/gems/web_translate_it-1.6.2/lib/web_translate_it/configuration.rb:22:in `initialize'
    from /Library/Ruby/Gems/1.8/gems/web_translate_it-1.6.2/lib/web_translate_it/command_line.rb:127:in `new'
    from /Library/Ruby/Gems/1.8/gems/web_translate_it-1.6.2/lib/web_translate_it/command_line.rb:127:in `fetch_configuration'
    from /Library/Ruby/Gems/1.8/gems/web_translate_it-1.6.2/lib/web_translate_it/command_line.rb:57:in `push'
    from /Library/Ruby/Gems/1.8/gems/web_translate_it-1.6.2/lib/web_translate_it/command_line.rb:31:in `run'
    from /Library/Ruby/Gems/1.8/gems/web_translate_it-1.6.2/bin/wti:5
    from /usr/bin/wti:19:in `load'
    from /usr/bin/wti:19

Cheers.

Rails 2.3.5, ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]

`wti push` crashes on non-existent files

When the Project API serve a file path that doesn’t exist on a project, wti push crashes because it attempts to open a file that doesn’t exist.
Ideally it should display an error message saying the file doesn’t exist and skip to the next file.

wti server logging

Hey Édouard,

Could I request that logging of the output from the pull actions in server.rb be added. We've been having problems with the server not pulling down changes and some output from the shell commands called would be most handy.

In our setup the sinatra app is being served by mongrel via an init script that runs wti server which we ProxyPass via apache; we're not using a config.ru (I note that many of the logging configurations for sinatra define a logger this way). We could however serve the sinatra app via passenger instead if this make things easier.

Cheers.

Use file names from the Project API instead of the [locale] trick

It doesn’t work well for po/pot files. Also it would be much easier to set up.

The project API gives:

--- 
project: 
  name: Web Translate It
  source_locale: 
    name: English
    code: en
  target_locales: 
  - name: English
    code: en
    type: Locale
  - name: French
    code: fr
    type: Locale
  project_files: 
  - name: app/en.yml
    master: true
    id: 1941
  - name: app/fr.yml
    master: false
    id: 1942
  - name: defaults/fr.yml
    master: false
    id: 1944
  - name: defaults/en.yml
    master: true
    id: 1943

wti server doesn't notice new languages

Hey Édouard,

As far as I can tell, it appears that the only way to get the server to notice that their is a new language is to restart it, which is a bit of a pain. I'd hoped that fetching all languages might update the drop-down with the new language.

Cheers,
James.

Middleware should log, not puts

Currently it only puts what the plugin does in the logs:
Looking for fr_FR translations... Done. Response code: 200

It would be better off in log/webtranslateit.log so users can dig in it.

nil output on wti push

When firing the gem command

wti push

I receive an answer like this

Pushing config/locales/en.yml… nil

Add support for multi-file projects

Web Translate It’s new API allows fetching strings file by file.
The plugin should be updated to use the API.

Refactor the plugin and change the configuration file to used like so:

api_key: SECRET
master_locale: en
files:
  wti_id: config/locales/file1_[locale].yml
  wti_id: config/locales/file2_[locale].yml
development:
  autofetch: true
staging:
  autofetch: true
production:
  autofetch: false

`wti pull` retuning unexpected 304s

Hey,

Last night one of our translators finished off a bunch of Chinese strings. This morning I wanted to pull them down so I did a wti pull -l zh. All the files returned returned a 304 Not Modified and none were downloaded. I deleted one of the files I knew had been updated, from my local repo and re-pulled and the updated file was pulled down. How does wti determine whether a given file is modified?

Thanks.

Command aliases

wti st --> wti stats
wti status --> wti stats
wti help --> wti --help
wti anything > wti: 'anything' is not a wti command. See 'wti --help'.
wti init --> wti autoconf

Not compatible with Ruby 1.9.2.rc2

Error message when running 'wti autoconf':

~/Programming/someproject[master]% wti autoconf 
/Users/matt/.rvm/gems/ruby-1.9.2-rc2/gems/web_translate_it-1.7.0.4/lib/web_translate_it/translation_file.rb:12:in `require': no such file to load -- ftools (LoadError)
    from /Users/matt/.rvm/gems/ruby-1.9.2-rc2/gems/web_translate_it-1.7.0.4/lib/web_translate_it/translation_file.rb:12:in `<class:TranslationFile>'
    from /Users/matt/.rvm/gems/ruby-1.9.2-rc2/gems/web_translate_it-1.7.0.4/lib/web_translate_it/translation_file.rb:8:in `<module:WebTranslateIt>'
    from /Users/matt/.rvm/gems/ruby-1.9.2-rc2/gems/web_translate_it-1.7.0.4/lib/web_translate_it/translation_file.rb:1:in `<top (required)>'
    from /Users/matt/.rvm/gems/ruby-1.9.2-rc2/gems/web_translate_it-1.7.0.4/lib/web_translate_it.rb:4:in `require'
    from /Users/matt/.rvm/gems/ruby-1.9.2-rc2/gems/web_translate_it-1.7.0.4/lib/web_translate_it.rb:4:in `<top (required)>'
    from /Users/matt/.rvm/gems/ruby-1.9.2-rc2/gems/web_translate_it-1.7.0.4/bin/wti:4:in `require'
    from /Users/matt/.rvm/gems/ruby-1.9.2-rc2/gems/web_translate_it-1.7.0.4/bin/wti:4:in `<top (required)>'
    from /Users/matt/.rvm/gems/ruby-1.9.2-rc2/bin/wti:19:in `load'
    from /Users/matt/.rvm/gems/ruby-1.9.2-rc2/bin/wti:19:in `<main>'

Rack middleware

The auto-fetch functionality would work better as a rack middleware.

Ability to force translation fetch

Even if we have the file up to date (and thus Web Translate It respond 304 Not Modified), we sometimes want to get the translation again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.