GithubHelp home page GithubHelp logo

po3way's Introduction

po3way

Three way merger for gettext po file that can act as a git merge driver.

Why a specific git merge driver for po files?

I give you an example:

msgid ""
"This is an example "
"which span on multiple lines."
msgstr ""

In one branch, someone translate it, so it become:

msgid ""
"This is an example "
"which span on multiple lines."
msgstr ""
"C'est un exemple "
"qui s'étend sur plusieurs lignes."

In another branch it gets updated, so it become:

msgid ""
"This is an updated example "
"which span on multiple lines."
msgstr ""

If we run a 3-way merge on this, we'll get no conflict because those are two distinct modifications ("shielded" by the msgstr "" line), so it become:

msgid ""
"This is an update example "
"which span on multiple lines."
msgstr ""
"C'est un exemple "
"qui s'étend sur plusieurs lignes."

Which is particularily bad for a po file, it would clearly need a fuzzy flag and some human intervention, but no, it gets merged silently.

Let alone this very specific case, po3way often provide very clean and understandable conflicts which are easier to merge than "normal" conflicts, like:

where the base was fuzzy, remote fixed it, but local updated again!

How it works

There's no magic, po3way works using the following steps:

  • Rewrite the .po file such that it's easier and safer to diff. This step is a bit like using msgcat --no-wrap but in a way we can undo deterministically.
  • Use git merge-file to actually do the 3-way merge, I don't want to rewrite it from scratch.
  • Undo the first step to get your original wrapping back.
  • Automatically solve easy conflicts like updated POT-Creation-Date / PO-Revision-Date while we're here.

How to install

From pypi:

python -m pip install po3way

From sources:

python -m pip install .

How to use

The arguments are the same than diff3, so:

po3way local.po base.po remote.po

How to use as a git merge driver

There's two things to do, first configure git to learn about the po3way tool, either in your ~/.gitconfig or in your .git/config:

[merge "po3way"]
    name = po file merge driver
    driver = po3way --git-merge-driver -- %A %O %B

Then in your project add a .gitattributes file telling that po files should be merged using po3way:

*.po merge=po3way

Contributing

There's a --debug argument to make po3way keep its intermediate files so you can take a look at them. Just ls -lahtr /tmp to find them, they should be hanging around in a directory prefixed by tmp.

po3way's People

Contributors

julienpalard avatar

Stargazers

Maxime Péloquin avatar Valentin Laurent avatar édith avatar Abhilash Raj avatar Sanyam Khurana avatar Maciej Olko avatar

Watchers

 avatar James Cloos avatar  avatar édith avatar eviau-sat avatar

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.