Skip to content
yuichiro umezawa edited this page Jul 30, 2017 · 18 revisions

po4a

po4a で翻訳作業を機械化できそう。以下、trusty での作業メモ

# garbagetown @ garbagetown in ~/Desktop/trusty [5:45:54] 
$ cat Vagrantfile 
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://vagrantcloud.com/search.
  config.vm.box = "ubuntu/trusty64"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # NOTE: This will enable public access to the opened port
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine and only allow access
  # via 127.0.0.1 to disable public access
  # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network "private_network", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Enable provisioning with a shell script. Additional provisioners such as
  # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end

# garbagetown @ garbagetown in ~/Desktop/trusty [5:45:58] 
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'ubuntu/trusty64' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'ubuntu/trusty64'
    default: URL: https://vagrantcloud.com/ubuntu/trusty64
==> default: Adding box 'ubuntu/trusty64' (v20170619.0.0) for provider: virtualbox
    default: Downloading: https://vagrantcloud.com/ubuntu/boxes/trusty64/versions/20170619.0.0/providers/virtualbox.box
==> default: Successfully added box 'ubuntu/trusty64' (v20170619.0.0) for 'virtualbox'!
==> default: Importing base box 'ubuntu/trusty64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: Setting the name of the VM: trusty_default_1501447807425_55456
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
(snip)
    default: 
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default: 
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default: 
    default: Guest Additions Version: 4.3.36
    default: VirtualBox Version: 5.1
==> default: Mounting shared folders...
    default: /vagrant => /Users/garbagetown/Desktop/trusty
# garbagetown @ garbagetown in ~/Desktop/trusty [5:51:44] 
$ vagrant ssh
Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-125-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

 System information disabled due to load higher than 1.0

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

0 packages can be updated.
0 updates are security updates.

New release '16.04.2 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


_____________________________________________________________________
WARNING! Your environment specifies an invalid locale.
 This can affect your user experience significantly, including the
 ability to manage packages. You may install the locales by running:

   sudo apt-get install language-pack-ja
     or
   sudo locale-gen ja_JP.UTF-8

To see all available language packs, run:
   apt-cache search "^language-pack-[a-z][a-z]$"
To disable this message for all users, run:
   sudo touch /var/lib/cloud/instance/locale-check.skip
_____________________________________________________________________

vagrant@vagrant-ubuntu-trusty-64:~$ which git
vagrant@vagrant-ubuntu-trusty-64:~$ which wget
/usr/bin/wget

vagrant@vagrant-ubuntu-trusty-64:~$ sudo apt-get install git
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  git-man liberror-perl
Suggested packages:
  git-daemon-run git-daemon-sysvinit git-doc git-el git-email git-gui gitk
  gitweb git-arch git-bzr git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
  git git-man liberror-perl
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 3361 kB of archives.
After this operation, 21.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu/ trusty/main liberror-perl all 0.17-1.1 [21.1 kB]
Get:2 http://archive.ubuntu.com/ubuntu/ trusty-updates/main git-man all 1:1.9.1-1ubuntu0.5 [699 kB]
Get:3 http://archive.ubuntu.com/ubuntu/ trusty-updates/main git amd64 1:1.9.1-1ubuntu0.5 [2641 kB]
Fetched 3361 kB in 13s (246 kB/s)                                              
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_CTYPE = "ja_JP.UTF-8",
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Selecting previously unselected package liberror-perl.
(Reading database ... 63129 files and directories currently installed.)
Preparing to unpack .../liberror-perl_0.17-1.1_all.deb ...
Unpacking liberror-perl (0.17-1.1) ...
Selecting previously unselected package git-man.
Preparing to unpack .../git-man_1%3a1.9.1-1ubuntu0.5_all.deb ...
Unpacking git-man (1:1.9.1-1ubuntu0.5) ...
Selecting previously unselected package git.
Preparing to unpack .../git_1%3a1.9.1-1ubuntu0.5_amd64.deb ...
Unpacking git (1:1.9.1-1ubuntu0.5) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up liberror-perl (0.17-1.1) ...
Setting up git-man (1:1.9.1-1ubuntu0.5) ...
Setting up git (1:1.9.1-1ubuntu0.5) ...
vagrant@vagrant-ubuntu-trusty-64:~$ which git
/usr/bin/git
vagrant@vagrant-ubuntu-trusty-64:~$ apt-cache search po4a
po4a - tools for helping translation of documentation
dl10n - Debian infrastructure and tools for localization
sisu - documents - structuring, publishing in multiple formats and search

vagrant@vagrant-ubuntu-trusty-64:~$ sudo apt-get install po4a
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  gettext libasprintf-dev libcroco3 libgettextpo-dev libgettextpo0
  libmime-charset-perl libsgmls-perl libsombok3 libsp1c2 libterm-readkey-perl
  libunicode-linebreak-perl libunistring0 sp
Suggested packages:
  gettext-doc libencode-hanextra-perl sgmls-doc sgmlspl doc-base sgml-data
The following NEW packages will be installed:
  gettext libasprintf-dev libcroco3 libgettextpo-dev libgettextpo0
  libmime-charset-perl libsgmls-perl libsombok3 libsp1c2 libterm-readkey-perl
  libunicode-linebreak-perl libunistring0 po4a sp
0 upgraded, 14 newly installed, 0 to remove and 0 not upgraded.
Need to get 4072 kB of archives.
After this operation, 15.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu/ trusty/main libcroco3 amd64 0.6.8-2ubuntu1 [82.4 kB]
Get:2 http://archive.ubuntu.com/ubuntu/ trusty/main libunistring0 amd64 0.9.3-5ubuntu3 [271 kB]
Get:3 http://archive.ubuntu.com/ubuntu/ trusty-updates/main libgettextpo0 amd64 0.18.3.1-1ubuntu3 [108 kB]
Get:4 http://archive.ubuntu.com/ubuntu/ trusty/main libsombok3 amd64 2.3.1-2 [29.9 kB]
Get:5 http://archive.ubuntu.com/ubuntu/ trusty-updates/main gettext amd64 0.18.3.1-1ubuntu3 [829 kB]
Get:6 http://archive.ubuntu.com/ubuntu/ trusty-updates/main libasprintf-dev amd64 0.18.3.1-1ubuntu3 [4438 B]
Get:7 http://archive.ubuntu.com/ubuntu/ trusty-updates/main libgettextpo-dev amd64 0.18.3.1-1ubuntu3 [122 kB]
Get:8 http://archive.ubuntu.com/ubuntu/ trusty/main libmime-charset-perl all 1.011.1-1 [31.9 kB]
Get:9 http://archive.ubuntu.com/ubuntu/ trusty/main libsgmls-perl all 1.03ii-32 [29.4 kB]
Get:10 http://archive.ubuntu.com/ubuntu/ trusty/main libsp1c2 amd64 1.3.4-1.2.1-47.3ubuntu1 [1026 kB]
Get:11 http://archive.ubuntu.com/ubuntu/ trusty/main libterm-readkey-perl amd64 2.31-1 [27.4 kB]
Get:12 http://archive.ubuntu.com/ubuntu/ trusty/main libunicode-linebreak-perl amd64 0.0.20131101-1 [92.7 kB]
Get:13 http://archive.ubuntu.com/ubuntu/ trusty/main sp amd64 1.3.4-1.2.1-47.3ubuntu1 [124 kB]
Get:14 http://archive.ubuntu.com/ubuntu/ trusty/main po4a all 0.45-1 [1294 kB] 
Fetched 4072 kB in 27s (146 kB/s)                                              
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_CTYPE = "ja_JP.UTF-8",
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Selecting previously unselected package libcroco3:amd64.
(Reading database ... 63877 files and directories currently installed.)
Preparing to unpack .../libcroco3_0.6.8-2ubuntu1_amd64.deb ...
Unpacking libcroco3:amd64 (0.6.8-2ubuntu1) ...
Selecting previously unselected package libunistring0:amd64.
Preparing to unpack .../libunistring0_0.9.3-5ubuntu3_amd64.deb ...
Unpacking libunistring0:amd64 (0.9.3-5ubuntu3) ...
Selecting previously unselected package libgettextpo0:amd64.
Preparing to unpack .../libgettextpo0_0.18.3.1-1ubuntu3_amd64.deb ...
Unpacking libgettextpo0:amd64 (0.18.3.1-1ubuntu3) ...
Selecting previously unselected package libsombok3:amd64.
Preparing to unpack .../libsombok3_2.3.1-2_amd64.deb ...
Unpacking libsombok3:amd64 (2.3.1-2) ...
Selecting previously unselected package gettext.
Preparing to unpack .../gettext_0.18.3.1-1ubuntu3_amd64.deb ...
Unpacking gettext (0.18.3.1-1ubuntu3) ...
Selecting previously unselected package libasprintf-dev:amd64.
Preparing to unpack .../libasprintf-dev_0.18.3.1-1ubuntu3_amd64.deb ...
Unpacking libasprintf-dev:amd64 (0.18.3.1-1ubuntu3) ...
Selecting previously unselected package libgettextpo-dev:amd64.
Preparing to unpack .../libgettextpo-dev_0.18.3.1-1ubuntu3_amd64.deb ...
Unpacking libgettextpo-dev:amd64 (0.18.3.1-1ubuntu3) ...
Selecting previously unselected package libmime-charset-perl.
Preparing to unpack .../libmime-charset-perl_1.011.1-1_all.deb ...
Unpacking libmime-charset-perl (1.011.1-1) ...
Selecting previously unselected package libsgmls-perl.
Preparing to unpack .../libsgmls-perl_1.03ii-32_all.deb ...
Unpacking libsgmls-perl (1.03ii-32) ...
Selecting previously unselected package libsp1c2.
Preparing to unpack .../libsp1c2_1.3.4-1.2.1-47.3ubuntu1_amd64.deb ...
Unpacking libsp1c2 (1.3.4-1.2.1-47.3ubuntu1) ...
Selecting previously unselected package libterm-readkey-perl.
Preparing to unpack .../libterm-readkey-perl_2.31-1_amd64.deb ...
Unpacking libterm-readkey-perl (2.31-1) ...
Selecting previously unselected package libunicode-linebreak-perl.
Preparing to unpack .../libunicode-linebreak-perl_0.0.20131101-1_amd64.deb ...
Unpacking libunicode-linebreak-perl (0.0.20131101-1) ...
Selecting previously unselected package sp.
Preparing to unpack .../sp_1.3.4-1.2.1-47.3ubuntu1_amd64.deb ...
Unpacking sp (1.3.4-1.2.1-47.3ubuntu1) ...
Selecting previously unselected package po4a.
Preparing to unpack .../archives/po4a_0.45-1_all.deb ...
Unpacking po4a (0.45-1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Processing triggers for install-info (5.2.0.dfsg.1-2) ...
Setting up libcroco3:amd64 (0.6.8-2ubuntu1) ...
Setting up libunistring0:amd64 (0.9.3-5ubuntu3) ...
Setting up libgettextpo0:amd64 (0.18.3.1-1ubuntu3) ...
Setting up libsombok3:amd64 (2.3.1-2) ...
Setting up gettext (0.18.3.1-1ubuntu3) ...
Setting up libasprintf-dev:amd64 (0.18.3.1-1ubuntu3) ...
Setting up libgettextpo-dev:amd64 (0.18.3.1-1ubuntu3) ...
Setting up libmime-charset-perl (1.011.1-1) ...
Setting up libsgmls-perl (1.03ii-32) ...
Setting up libsp1c2 (1.3.4-1.2.1-47.3ubuntu1) ...
Setting up libterm-readkey-perl (2.31-1) ...
Setting up libunicode-linebreak-perl (0.0.20131101-1) ...
Setting up sp (1.3.4-1.2.1-47.3ubuntu1) ...
Setting up po4a (0.45-1) ...
Processing triggers for libc-bin (2.19-0ubuntu6.13) ...

vagrant@vagrant-ubuntu-trusty-64:~$ which po4a
/usr/bin/po4a
vagrant@vagrant-ubuntu-trusty-64:~$ cd /vagrant/

vagrant@vagrant-ubuntu-trusty-64:/vagrant$ git clone https://github.com/playframework/playframework.git
Cloning into 'playframework'...
remote: Counting objects: 155641, done.
remote: Compressing objects: 100% (128/128), done.
remote: Total 155641 (delta 59), reused 106 (delta 24), pack-reused 155461
Receiving objects: 100% (155641/155641), 85.50 MiB | 440.00 KiB/s, done.
Resolving deltas: 100% (74647/74647), done.
Checking connectivity... done.
Checking out files: 100% (1822/1822), done.
vagrant@vagrant-ubuntu-trusty-64:/vagrant$ cd playframework/
vagrant@vagrant-ubuntu-trusty-64:/vagrant/playframework$ git config core.sparsecheckout true
vagrant@vagrant-ubuntu-trusty-64:/vagrant/playframework$ touch .git/info/sparse-checkout
vagrant@vagrant-ubuntu-trusty-64:/vagrant/playframework$ echo documentation/manual/ > .git/info/sparse-checkout
vagrant@vagrant-ubuntu-trusty-64:/vagrant/playframework$ git read-tree -m -u HEAD
vagrant@vagrant-ubuntu-trusty-64:/vagrant/playframework$ cd ..

vagrant@vagrant-ubuntu-trusty-64:/vagrant$ mkdir translation-project

vagrant@vagrant-ubuntu-trusty-64:/vagrant$ find playframework/documentation/manual/ -type d | sed "s/playframework\///g" | xargs -i mkdir -p translation-project/{}

vagrant@vagrant-ubuntu-trusty-64:/vagrant$ find playframework/documentation/manual/ -type d | sed "s/playframework\/documentation\///g" | xargs -i mkdir -p translation-project/po/{}

vagrant@vagrant-ubuntu-trusty-64:/vagrant$ find playframework/documentation/ -name "*.md" | sed "s/playframework\/documentation\///g" | xargs -i po4a-updatepo -f text -o markdown -M UTF-8 -m playframework/documentation/{} -p translation-project/po/{}_ja.po
vagrant@vagrant-ubuntu-trusty-64:/vagrant$ find playframework/documentation/ -name "*.md" | sed "s/playframework\/documentation\///g" | xargs -i po4a-translate -f text -o markdown -M UTF-8 -k 0 -m playframework/documentation/{} -p translation-project/po/{}_ja.po -l translation-project/documentation/{}
Clone this wiki locally