SVN for Localizers 编辑

Welcome to the SVN tutorial for localizers! Here you'll learn the process of using SVN to obtain Mozilla website source files from the Mozilla servers and pushing your localizations right back to them. First things first, we need to give you a brief introduction to what SVN is and where you can find the necessary tools to get started. If you're already familiar with this information, skip ahead to Mozilla's SVN repositories.

Brief intro to SVN

SVN (abbreviation for Subversion) is a free and open source repository tool we use to manage the localized Mozilla web pages. It's a handy tool that allows us to grab, change, and store versions of source files in one location. You should know that when we say SVN we are referring to either the SVN server and the SVN client. This may seem confusing, but don't fret because we'll make sure to differentiate between the two here:

  • SVN server: This is installed on one of Mozilla's servers that we use to manage our localizable web system.
  • SVN client: This is what a localizer installs on their own computer. The SVN client is the localizer's communication portal for accessing the Mozilla SVN server. You use it to copy files from the server to your computer and to push changed or localized files back onto the server.

Installing SVN client:

  • Linux users can download the SVN client from http://subversion.apache.org/packages.html or install packages provided within their distribution (for example, in Debian, sudo apt-get install subversion).
  • Mac OS X users can find SVN inside the Command Line Tools (available on the Apple Developer website), or use tools like Homebrew or Fink.
  • Windows users can install the SVN client directly from the Cygwin setup file. If you already installed Cygwin but it didn't include the SVN package, run the Cygwin installer again and be sure to check the box beside Subversion package. This option is found in the Devel category. A possible alternative is to install TortoiseSVN (graphical interface and command line client).
Note: If you do not already have access to SVN, visit this wiki page on how to get set up with an SVN account before proceeding.

Mozilla's SVN repositories

Mozilla's SVN server is publicly available at https://svn.mozilla.org. Despite there being several directories at the root of the SVN server, only the projects and mozillamessaging.comdirectories apply to web localizers.

For this tutorial we'll use the mozilla.com project. Here's the layout you will find within the projects/mozilla.com directory:

  • Navigating from the command-line with your SVN client, you'll find three directories within projects/mozilla.com. The trunk directory is what you are most insterested in. Trunk refers to a set of files and directories that are in the testing stage (i.e., staging). All file modifications belong in trunk because they are seen most frequently.
  • Inside mozilla.com/trunk/locales, there are separate directories for each locale that is localizing mozilla.com. In each of those locale directories are other directories with files to be localized in .langformat.
Note: We use the terms stage and prod (abbreviations of the terms staging and production) to refer to testing and publicly visible websites, respectively.

Working with SVN

Now that you understand the Mozilla SVN repository layout (in particular the layout for mozilla.com), let's get some files into your hands to start localizing!

The first thing you need to do is copy the Mozilla repository you want to work on to your computer.

  1. Enter the following command in your command-line tool:
svn checkout https://svn.mozilla.org/projects/mozilla.com/trunk/locales/[your locale code] mozilla-l10n-[your-localeCode]

This command creates the mozilla-l10n-[your-localeCode] directory on your computer and copies into it all of the files from https://svn.mozilla.org/projects/moz...om/trunk/locales/[your locale code].

Note: The directory you create will be located inside the directory that you're currently in with your console (or Cygwin console).
Also, we use https instead of http because changes can only be pushed back to the Mozilla SVN Repository through a secure connection.
  1. Open the files you want to translate with your favorite text editor.
  2. Translate the content in those files, save them and check for differences by entering this command from the command-line:
svn diff

This command produces output with every change made to each file. It's a bit hard to read, but you can also create a diff file (aka a diff patch) use svn diff > /path/to/output/file.diff to save the output to a file. Note that path/to/output is meant to indicate the directory on your computer where you wish to store the diff file.

You can also run

svn status

to check the list of modified files (they'll display a M before the name) you're about to commit.

  1. Once you're satisfied with changes, commit them to the appropriate Mozilla SVN repository by entering the following command:
svn commit -m "Minor modifications for Firefox [version #] beta page for [your locale]"

The svn commit command will commit your changes directly to the Mozilla SVN repositories. Since you are writing to the repository here, you will be asked for your LDAP login credentials.

The -m parameter followed by some text within double quotes (") will be pushed along with your changes. Within the double quotes you should briefly describe your changes so that everyone can see what you contributed.

You can also double check your changes using the ViewVC interface.

  1. After you commit your changes, wait 15 minutes and check the staging website for your locale. Your recent changes should now be visible online. You will have the chance to see how the localized website will look when it's pushed to prod (i.e., a website that regular visitors will see).
  1. When localizing websites, l10n-drivers will always add needed files to your repository or update your files with new strings in English. It's very important for you to update your working copy with the newest files from Mozilla SVN repository before you start making changes. Enter the following command from the command-line:
svn update

Your local SVN repository (i.e., working directory) will be updated with the newest files from the URL you initially cloned your repository from. It's very important that you do this often. As a general rule, you should at least do it before translating anything.

  1. Sometimes mistakes happen and you need to start over. Go back to the root of your working directory and execute this command:
svn revert *

This is a really helpful command because it reverts all of your changes to your working directory's last updated state. This is a huge blessing if you have been updating frequently. It's a nightmare if you haven't because it throws away all of your recent hard work. Keep this in mind because if you did a lot of work and you made some errors in just one file, maybe it would be wiser to simply correct those errors instead of reverting your working directory and losing all your work.

Note: sometimes you'll find references to commands in abbreviated form (svn ci = svn commit, svn up = svn update, svn co = svn checkout, etc.)

Commit doesn't work, what's wrong?

  • Make you sure you're checking out the repository with https://
  • Make sure you're adding a commit message when running svn commit. Commits with an empty message will be rejected.
  • SVN accounts are disabled after 6 months of inactivity. To be used again, they need to be reenabled.

If you have any doubts, ping l10n-drivers on IRC in the #l10n channel.

Off to the races!

Congratulations! You should now be able to use SVN from the command-line to copy directories from the Mozilla repositories, make modifications to those repositories by using SVN commands like svn up and svn revert, and finally push your localized work to the Mozilla repositories. If you forget any of the information on this page, don't worry, you can always come back and review. It won't go anywhere any time soon!

Back to the localization home page.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:25 次

字数:11563

最后编辑:8年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文