将标签从项目导出到Excel [英] Exporting labels to Excel from a project

查看:95
本文介绍了将标签从项目导出到Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小问题-我必须列出几个大型共享项目的所有标签,以便标识缺少翻译的标签.

I have a small problem - I have to list all the labels of several large shared projects, so labels that are missing a translation are identified updated.

现在我正在寻找的东西类似于Palle Agermark的标签导出作业( http://www.agermark.com/2011/10/export-and-import-labels-for.html ),但需要经历一个或多个项目并提取所有标签ID的项目(无论标签系列如何)和Excel三种语言的值.

Now what I'm looking is something like Palle Agermark's label export job (http://www.agermark.com/2011/10/export-and-import-labels-for.html) but one that goes through one or more projects and pulls all the label IDs (regardless of label series) and values for three languages to Excel.

可以做到这一点吗? :)

Can this be done, any pointers? :)

推荐答案

这扩展了Jan B. Kjeldsen的最后评论的想法,即从项目xpo文件中获取标签.标签以以下XML结构保存在xpo文件中:

This expands the idea of Jan B. Kjeldsen's last comment to get the labels from the project xpo file. The labels are saved in the xpo file in the following XML structure:

<Table:Record name="TmpSysLabel" xmlns:Table='urn:www.microsoft.com/Formats/Table'>
    <Table:Field name="Language">de</Table:Field>
    <Table:Field name="Label">Geplante Produktionsaufträge</Table:Field>
    <Table:Field name="Description"></Table:Field>
    <Table:Field name="LabelId">@SYS119128</Table:Field>
    <Table:Field name="SysLabelApplModule">0</Table:Field>
    <Table:Field name="recVersion">0</Table:Field>
    <Table:Field name="Partition">5637144576</Table:Field>
</Table:Record>

我的第一个想法是将该XML导入Excel,但是Excel在属性中使用列名时效果不佳.因此,我写了一个xsl,将XML转换为以下内容:

My first idea was to import this XML to Excel, but Excel does not play nice with column names in attributes. So instead I wrote an xsl that transforms the XML into something like the following:

<?xml version="1.0" encoding="UTF-8"?>
<labels>
    <record>
        <Language>de</Language>
        <Label>Geplante Produktionsaufträge</Label>
        <Description />
        <LabelId>@SYS119128</LabelId>
        <SysLabelApplModule>0</SysLabelApplModule>
        <recVersion>0</recVersion>
        <Partition>5637144576</Partition>
    </record>
</labels>

要执行此转换,必须对原始XML进行一点清理,将所有Table:Record出现的内容替换为record,并将所有Table:Field出现的内容替换为field.还添加一个根XML节点labels.看起来应该是

To do this transformation, the original XML has to be cleaned up a bit, replace all occurences of Table:Record with record and all occurences of Table:Field with field. Also add a root XML node labels. It should look like

<labels>
    <record>
        <field name="Language">de</field>
        <field name="Label">Geplante Produktionsaufträge</field>
        <field name="Description"></field>
        <field name="LabelId">@SYS119128</field>
        <field name="SysLabelApplModule">0</field>
        <field name="recVersion">0</field>
        <field name="Partition">5637144576</field>
    </record>
</labels>

现在开始介绍有趣的部分(至少对我而言,因为我对xsl语法没有太多的先验知识),即xsl转换文件.最后,我将使用 http://www.freeformatter生成所需的XML. com/xsl-transformer.html :

Now for the fun part (at least for me because I had not much prior knowledge of xsl syntax), the xsl transformation file. I ended up with the following, which will produce the wanted XML using http://www.freeformatter.com/xsl-transformer.html:

<?xml version="1.0" encoding="utf-16"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes" indent="no" />
<xsl:template match="/">
    <labels>
    <xsl:for-each select="Labels/*">
        <record>
        <xsl:for-each select="*">
            <xsl:element name="{@name}">
                <xsl:value-of select="." />
            </xsl:element>
        </xsl:for-each>
        </record>
    </xsl:for-each>
    </labels>
</xsl:template>
</xsl:stylesheet>

然后可以使用用于XML的Excel开发人员工具将生成的XML导入Excel.结果看起来像

The resulting XML can then be imported into Excel using the Excel developer Tools for XML. The result will look like

这篇关于将标签从项目导出到Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆