Merge two PO files and overwrite matching translation rules - merge

I'm attempting to merge two PO files.
I have a base.po file that has general translations.
I have an extra.po which has extra translations that I'd like to add to the base file OR overwrite translations for if there are matching translation IDs.
I've tried using msgmerge:
$ msgmerge extra.po base.po -o merge.po
But this comments out any translations with matching IDs.
Looking at the msgmerge documentation, it doesn't look like there is any option to effect this behavior.
I'd like to be able to have multiple extra translation files (extra1.po, extra2.po, etc.) so I can merge them with the base translation file and use them in different contexts.
Does anyone know how to do what I'm attempting?

Turns out I needed to be using msgcat instead.
The below command creates a PO file merge.po that contains all of the translations from extra.po and adds any additional translations from base.po.
The --use-first option specifies that if there is a matching translation id between the two files, to choose the translation from extra.po.
$ msgcat extra.po base.po -o merge.po --use-first

Related

Include only specific file patterns in meld comparison

I want to compare directories with Meld, but only specific file patterns.
E.g., only *.c;*.cc;*.icc;*.h files.
Meld can use File Filters, but I could only use them for exclusion filtering specific file patterns. That approach is not useful for me, I guess.
Can an inclusion filter be applied?
I tried with the idea of "double negation": Excluding "everything but *.c;*.cc;*.icc;*.h", which in effect would include only those patterns.
I tried using File Filters which worked well for listing "everything but ..." using ls -d -- <my_filter> at the command line (see this). I assume this is a necessary (but not sufficient) condition for any filter to work in Meld.
None of these worked:
!(*.c|*.h|*.cc)
!(*#(.c|.h|.cc))
!(*.#(c|h|cc))
Note: I do not mean to use any type of Text Filter, since I do not care at this point about the contents of files, but only about the file names.
Note : I have bash and
$ shopt extglob
extglob on

asciidoc: is there a way to create an anchor that will be visible in libreoffice writer?

Tl;dr;
What is the correct way to create an anchor in docbook? and is there a way that will make the anchor visible in writer?
Background
I am trying to split up documentation that was previously in single open office documents into smaller asciidoc documents which are both included in the main open office document and also converted to either or both of html & pdf.
I have this mostly working. I use asciidoctor to create html. asciidoctor-pdf to create pdf and a combination of asciidoctor and pandoc to create .odt files. I also tried the python implementation of asciidoc but found the interface less useable.
Round tripping between asciidoc and odt is obviously not possible. This is sort of a fusion where the master document is word processed but pieces of content that can be produced independently (think man pages - in fact that is one of several use cases) are included.
asciidoc to html:
asciidoctor -b html5 foo.adoc -o foo.html
asciidoc to pdf:
asciidoctor-pdf -b pdf foo.adoc -o foo.pdf
asciidoc to odt
asciidoctor -b docbook foo.adoc -o foo.docbook
pandoc --base-header-level=3 -V date:"" -V title:"" -f docbook foo.docbook -o foo.odt
With pandoc I have to nullify the date and title and set the header-level as desired for the section to be inserted as an extra complication.
I insert the resulting .odt into the main document using insert section inside open office.
Note that the main document is not a master document as I could not find a way of creating a master document without also automatically splitting the file on h1 boundaries.
I have two main problems to resolve with this set-up. I would like to add headings in the asciidoc document as cross references and also create entries for them in the alphabetical index (actually the first heading would be suffcient). Is there a way to do this?
Index markers in asciidoc do not result in entries in .odt file being created.
I am able to cross reference content in the inserted section using "insert reference/heading" and referencing the uniquely named header. However, whenever I use "update all" these cross references are invalidated. They are shown as "Error: Reference source not found".
[On a separate note I would also like a way to find broken cross references automatically]
I am currently using libreoffice - Version: 4.3.7.2
I am not adverse to switching version or flavours (i.e. apache) if one behaves better than the other.
I'm not sure if the answer is in the asciidoc or docbook parts of the chain. I would accept an answer which inserts a index entry at the start of the inserted section (top of the .adoc/docbook file) automatically.
I am also open to changing my toolchain to something that will work.
For example I tried the asciidoc-odt backend and fell foul of https://github.com/dagwieers/asciidoc-odf/issues/47 which does not inspire confidence.
Using asciidoc-odt I avoid the need to create an intermediate docbook file. However, I still can't get the anchor to appear.
I can get a macro to create an anchor but at present I haven't figured out how to run the macro from the command line.
To create an anchor in DocBook, make an inline anchor in the .adoc file. For example, giving this to asciidoctor:
[[X1]]Section1
---------------
produced this:
<title>
<anchor xml:id="X1" xreflabel="[X1]"/>
Section1
</title>
Conversely, putting this on separate lines did not create an anchor tag in my test:
[[X1]]
Section 1
Now for some bad news. From the Pandoc User's Guide:
Internal links are currently supported for HTML formats (including HTML slide shows and EPUB), LaTeX, and ConTeXt.
I interpret this to mean that currently, Pandoc does not create internal links in Writer. When I tried it, the link was ignored.
Note: It looks like I did not answer all of your questions. If you want to ask more about LibreOffice cross references and headings (the big bold paragraph towards the end of the question), maybe you could make a separate question just for that part.

How to join two files in Linux for example if i have many files

I have 133 files named as Trace1.log Trace2.log and so on so how can I merge all these files together and save it in one
To simply concatenate the files in alphabetical order,
cat Trace*.log >combined
Take care to name the destination file so it doesn't match the wildcard, or you will get weird results.
Alphabetical order means Trace10.log sorts before Trace2.log. If you need them in numeric order, use a more suitable naming convention (e.g. rename Trace1.log to Trace001.log, etc) or use multiple wildcards;
cat Trace?.log Trace??.log Trace???.log >combined
The locale will affect what exactly "alphabetic order" means; these guidelines apply to the traditional C locale and English-language locales at least (and most other Western languages).
You can try using the cat command.
$ cat Trace* > TraceFull.log
Take a look at this site Joining files together
if you're on a unix based system use the following command:
cat Trace*.log > TraceMerged.log
(while in the directory holding the logs)

Concatenate content of TAGS files from different directories

I'm referring to TAGS file generated by ctags or etags in order to have some code navigation in Emacs with M-..
The typical project looks like this:
Large standard library (more than 100 files, but rarely updated).
Project-specific library (updated on the daily basis).
I would like the project to be able to use two (or maybe more TAGS files), but regenerate only the portion of them, only the ones used inside the particular project. How would I approach this problem?
etags --help:
-i FILE, --include=FILE
Include a note in tag file indicating that, when searching for
a tag, one should also consult the tags file FILE after
checking the current file.

Can I use `diff -r` to just tell me the files that are in one of the trees that have changed in the other?

I want to generate a summary of the files that are in one tree that are also in the other, that have been modified in the second.
The use case is this: I have a product distribution, which contains web content files. Those files are then imported into a client-specific project, and may be modified from there. I now want to see all the files in the client-specific project that have changed since the prduct was imported, so I can update the product, and keep the client-specific changes.
I'm thinking something like this might work
diff -r productDistribution/WebContent clientProject/WebContent
However, there are a number of files that are in the client specific project that are not in the product distribution, that I am not concerned with in this process. Essentially, I want an 'outer join', in SQL parlance.
Ideally, I want to be able to create a patch that contains all the client-specific changes. Then, I can just overlay the new product files, and apply the patch, and I should be all set.
Any ideas?
By default diff only prints a single line for each file that is in only one of the trees, so it's easy to filter these out:
diff -r productDistribution/WebContent clientProject/WebContent | \
grep -v 'Only in clientProject'