Kaydet (Commit) 6c605023 authored tarafından Andras Timar's avatar Andras Timar

remove localization tool of obsoleted layout code

üst ca54c036
Tralay - Extract and translate strings in Layout xml files.
Translatable strings in layout xml files are attributes that have name
which starts with an underscore, eg
_title="Set Zoom"
_label="Whole Page"
Here is how it works
* Extract: generate out.sdf
../unxlngx6.pro/bin/tralay -l en-US zoom.xml > out.sdf
* Translate: do:
cat out.sdf > trans.sdf
sed 's/en-US\t/de\tde:/' out.sdf >> trans.sdf
* Merge: translate
../unxlngx6.pro/bin/tralay -m trans.sdf -l de zoom.xml > zoom-DE.xml
Running
dmake test
does something similar.
\ No newline at end of file
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include "layoutparse.hxx"
#define STRING( str ) String( str, RTL_TEXTENCODING_UTF8 )
#define BSTRING( str ) ByteString( str, RTL_TEXTENCODING_UTF8 )
LayoutXMLFile::LayoutXMLFile( bool mergeMode )
: XMLFile()
, mMergeMode( mergeMode )
{
}
void
LayoutXMLFile::SearchL10NElements( XMLParentNode* pCur, int )
{
if ( !pCur )
pCur = this;
/* Recurse int children, SearchL10NElements does not do that for us. */
if ( XMLChildNodeList* lst = pCur->GetChildList() )
for ( size_t i = 0; i < lst->size(); i++ )
if ( (*lst)[ i ]->GetNodeType() == XML_NODE_TYPE_ELEMENT )
HandleElement( ( XMLElement* )(*lst)[ i ] );
else if ( (*lst)[ i ]->GetNodeType() == XML_NODE_TYPE_COMMENT ) {
XMLChildNodeList::iterator it = lst->begin();
::std::advance( it, i );
lst->erase( it );
i--;
}
}
std::vector<XMLAttribute*>
interestingAttributes( XMLAttributeList* lst )
{
std::vector<XMLAttribute*> interesting;
if ( lst )
for ( size_t i = 0; i < lst->size(); i++ )
if ( (*lst)[ i ]->Equals( STRING( "id" ) ) )
interesting.insert( interesting.begin(), (*lst)[ i ] );
else if ( ! BSTRING( *(*lst)[ i ]).CompareTo( "_", 1 ) )
interesting.push_back( (*lst)[ i ] );
return interesting;
}
void
LayoutXMLFile::HandleElement( XMLElement* element )
{
std::vector<XMLAttribute*> interesting = interestingAttributes( element->GetAttributeList() );
if ( !interesting.empty() )
{
std::vector<XMLAttribute*>::iterator i = interesting.begin();
ByteString id = BSTRING( (*i++)->GetValue() );
if ( mMergeMode )
InsertL10NElement( id, element );
else
for ( ; i != interesting.end(); ++i )
{
ByteString attributeId = id;
ByteString value = BSTRING( ( *i )->GetValue() );
XMLElement *e = new XMLElement( *element );
e->RemoveAndDeleteAllChilds();
/* Copy translatable text to CONTENT. */
//new XMLData( STRING( ( *i )->GetValue() ), e, true );
new XMLData( STRING( value ), e, true );
attributeId += BSTRING ( **i );
InsertL10NElement( attributeId, e );
}
}
SearchL10NElements( (XMLParentNode*) element );
}
void LayoutXMLFile::InsertL10NElement( ByteString const& id, XMLElement* element )
{
ByteString const language = "en-US";
LangHashMap* languageMap = 0;
XMLHashMap::iterator pos = XMLStrings->find( id );
if ( pos != XMLStrings->end() )
{
languageMap = pos->second;
fprintf( stderr, "error:%s:duplicate translation found, id=%s\n",
id.GetBuffer(), BSTRING( sFileName ).GetBuffer() );
exit( 1 );
}
else
{
languageMap = new LangHashMap();
XMLStrings->insert( XMLHashMap::value_type( id , languageMap ) );
order.push_back( id );
}
(*languageMap)[ language ] = element;
}
sal_Bool LayoutXMLFile::Write( ByteString &aFilename )
{
if ( aFilename.Len() )
{
ofstream aFStream( aFilename.GetBuffer() , ios::out | ios::trunc );
if ( !aFStream )
fprintf( stderr, "ERROR: cannot open file:%s\n", aFilename.GetBuffer() );
else
{
XMLFile::Write( aFStream );
aFStream.close();
return true;
}
}
return false;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef LAYOUTPARSE_HXX
#define LAYOUTPARSE_HXX
#include "xmlparse.hxx"
class LayoutXMLFile : public XMLFile
{
bool mMergeMode;
public:
LayoutXMLFile( bool mergeMode );
void SearchL10NElements( XMLParentNode *pCur, int pos = 0 );
sal_Bool Write( ByteString &aFilename );
void HandleElement( XMLElement* element );
void InsertL10NElement( ByteString const& id, XMLElement* element );
using XMLFile::InsertL10NElement;
using XMLFile::Write;
};
std::vector<XMLAttribute*> interestingAttributes( XMLAttributeList* lst );
#endif /* LAYOUTPARSE_HXX */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
transex3 layout\workben\zoom-1.xml 0 help FL_ZOOM 0 en-US Zoom factor 20080204 13:51:01
transex3 layout\workben\zoom-1.xml 0 help BTN_WHOLE_PAGE 0 en-US Whole Page 20080204 13:51:01
transex3 layout\workben\zoom-1.xml 0 help BTN_PAGE_WIDTH 0 en-US Page Width 20080204 13:51:01
transex3 layout\workben\zoom-1.xml 0 help BTN_OPTIMAL 0 en-US Optimal 20080204 13:51:01
transex3 layout\workben\zoom-1.xml 0 help BTN_200 0 en-US 200 % 20080204 13:51:01
transex3 layout\workben\zoom-1.xml 0 help BTN_150 0 en-US 15~0 % 20080204 13:51:01
transex3 layout\workben\zoom-1.xml 0 help BTN_100 0 en-US 100 % 20080204 13:51:01
transex3 layout\workben\zoom-1.xml 0 help BTN_75 0 en-US 75 % 20080204 13:51:01
transex3 layout\workben\zoom-1.xml 0 help BTN_50 0 en-US 50 % 20080204 13:51:01
transex3 layout\workben\zoom-1.xml 0 help BTN_USER 0 en-US Variable 20080204 13:51:01
transex3 layout\workben\zoom-1.xml 0 help FL_ZOOM 0 de deZoom factor 20080204 13:51:01
transex3 layout\workben\zoom-1.xml 0 help BTN_WHOLE_PAGE 0 de deWhole Page 20080204 13:51:01
transex3 layout\workben\zoom-1.xml 0 help BTN_PAGE_WIDTH 0 de dePage Width 20080204 13:51:01
transex3 layout\workben\zoom-1.xml 0 help BTN_OPTIMAL 0 de deOptimal 20080204 13:51:01
transex3 layout\workben\zoom-1.xml 0 help BTN_200 0 de de200 % 20080204 13:51:01
transex3 layout\workben\zoom-1.xml 0 help BTN_150 0 de de15~0 % 20080204 13:51:01
transex3 layout\workben\zoom-1.xml 0 help BTN_100 0 de de100 % 20080204 13:51:01
transex3 layout\workben\zoom-1.xml 0 help BTN_75 0 de de75 % 20080204 13:51:01
transex3 layout\workben\zoom-1.xml 0 help BTN_50 0 de de50 % 20080204 13:51:01
transex3 layout\workben\zoom-1.xml 0 help BTN_USER 0 de deVariable 20080204 13:51:01
transex3 layout\workben\zoom-1.xml 0 help FL_ZOOM 0 en-US Zoom factor 20080204 13:51:01
transex3 layout\workben\zoom-1.xml 0 help BTN_WHOLE_PAGE 0 en-US Whole Page 20080204 13:51:01
transex3 layout\workben\zoom-1.xml 0 help FL_ZOOM 0 de de3:Zoom factor 20080204 13:51:01
transex3 layout\workben\zoom-1.xml 0 help BTN_WHOLE_PAGE 0 de de3:Whole Page 20080204 13:51:01
#*************************************************************************
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# Copyright 2000, 2010 Oracle and/or its affiliates.
#
# OpenOffice.org - a multi-platform office productivity suite
#
# This file is part of OpenOffice.org.
#
# OpenOffice.org is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# only, as published by the Free Software Foundation.
#
# OpenOffice.org is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License version 3 for more details
# (a copy is included in the LICENSE file that accompanied this code).
#
# You should have received a copy of the GNU Lesser General Public License
# version 3 along with OpenOffice.org. If not, see
# <http://www.openoffice.org/license.html>
# for a copy of the LGPLv3 License.
#
#*************************************************************************
PRJ=..
INCPRE=$(MISC)
PRJNAME=l10ntools
TARGET=tralay
TARGETTYPE=CUI
LIBTARGET=no
# --- Settings -----------------------------------------------------
ENABLE_EXCEPTIONS=TRUE
.INCLUDE : settings.mk
.IF "$(SYSTEM_EXPAT)" == "YES"
CFLAGS+=-DSYSTEM_EXPAT
.ENDIF
# --- Files --------------------------------------------------------
APP1TARGET=$(TARGET)
OBJFILES =\
$(OBJ)/export2.obj\
$(OBJ)/helpmerge.obj\
$(OBJ)/layoutparse.obj\
$(OBJ)/merge.obj\
$(OBJ)/tralay.obj\
$(OBJ)/xmlparse.obj
APP1OBJS = $(OBJFILES)
APP1RPATH = NONE
APP1STDLIBS =\
$(COMPHELPERLIB) \
$(TOOLSLIB)\
$(EXPATASCII3RDLIB)\
$(CPPULIB) \
$(SALLIB)
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
test .PHONY:
../$(INPATH)/bin/tralay -l en-US -o out.sdf zoom.xml
cat out.sdf > trans.sdf
sed 's/en-US\t/de\tde:/' out.sdf >> trans.sdf
../$(INPATH)/bin/tralay -m trans.sdf -l de -o zoom-DE.xml zoom.xml
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<!-- This is a template. i18n translation is not performed in-place;
i18n translated xml files are generated from this template by
transex3/layout/tralay. !-->
<modaldialog xmlns="http://openoffice.org/2007/layout"
xmlns:cnt="http://openoffice.org/2007/layout/container"
id="dialog" _title="Set Zoom" _label="boe" optimumsize="true"
help-id="SID_ATTR_ZOOM"
has_border="true" sizeable="true" moveable="true">
<vbox spacing="5" border="5">
<fixedline id="FL_ZOOM" _text="Zoom factor" _tooltip="bah" cnt:expand="true"/>
<radiobutton radiogroup="zoom" id="BTN_WHOLE_PAGE" _label="Whole Page"/>
<radiobutton radiogroup="zoom" id="BTN_PAGE_WIDTH" _label="Page Width"/>
<radiobutton radiogroup="zoom" id="BTN_OPTIMAL" _label="Optimal"/>
<radiobutton radiogroup="zoom" id="BTN_200" _label="200 %"/>
<radiobutton radiogroup="zoom" id="BTN_150" _label="15~0 %"/>
<radiobutton radiogroup="zoom" id="BTN_100" _label="100 %"/>
<radiobutton radiogroup="zoom" id="BTN_75" _label="75 %"/>
<radiobutton radiogroup="zoom" id="BTN_50" _label="50 %"/>
<hbox cnt:expand="false" cnt:fill="true">
<align cnt:expand="false" cnt:fill="true">
<radiobutton cnt:v-align="0.5" cnt:v-fill="0" radiogroup="zoom" id="BTN_USER" _label="Variable"/>
</align>
<flow cnt:padding="10" cnt:expand="false"/>
<metricfield id="ED_USER" value-step="1"
repeat="true" has_border="true" spin="true"
text="100%" unit="13" custom-unit-text="%"
right="true"
cnt:expand="false"/>
</hbox>
<fixedline cnt:padding="1" id="FL_BOTTOM"/>
<dialogbuttonhbox border="5" spacing="5">
<flow/>
<okbutton id="BTN_ZOOM_OK"/>
<cancelbutton id="BTN_ZOOM_CANCEL"/>
<helpbutton id="BTN_ZOOM_HELP"/>
</dialogbuttonhbox>
</vbox>
</modaldialog>
...@@ -2,7 +2,6 @@ tr l10ntools : tools LIBXSLT:libxslt BERKELEYDB:berkeleydb LUCENE:lucene NULL ...@@ -2,7 +2,6 @@ tr l10ntools : tools LIBXSLT:libxslt BERKELEYDB:berkeleydb LUCENE:lucene NULL
tr l10ntools usr1 - all tr_mkout NULL tr l10ntools usr1 - all tr_mkout NULL
tr l10ntools\inc nmake - all tr_inc NULL tr l10ntools\inc nmake - all tr_inc NULL
tr l10ntools\source nmake - all tr_src tr_inc NULL tr l10ntools\source nmake - all tr_src tr_inc NULL
tr l10ntools\layout nmake - all rt_layout tr_src tr_inc NULL
tr l10ntools\source\help nmake - all tr_bla_help NULL tr l10ntools\source\help nmake - all tr_bla_help NULL
tr l10ntools\source\filter\utils nmake - all tr_bla_utils NULL tr l10ntools\source\filter\utils nmake - all tr_bla_utils NULL
tr l10ntools\source\filter\merge nmake - all tr_bla_merge tr_bla_utils NULL tr l10ntools\source\filter\merge nmake - all tr_bla_merge tr_bla_utils NULL
...@@ -24,12 +24,9 @@ mkdir: %_DEST%\bin\help\com\sun\star\help ...@@ -24,12 +24,9 @@ mkdir: %_DEST%\bin\help\com\sun\star\help
..\%__SRC%\bin\ulfex %_DEST%\bin\ulfex ..\%__SRC%\bin\ulfex %_DEST%\bin\ulfex
..\%__SRC%\bin\txtconv.exe %_DEST%\bin\txtconv.exe ..\%__SRC%\bin\txtconv.exe %_DEST%\bin\txtconv.exe
..\%__SRC%\bin\txtconv %_DEST%\bin\txtconv ..\%__SRC%\bin\txtconv %_DEST%\bin\txtconv
..\%__SRC%\bin\tralay.exe %_DEST%\bin\tralay.exe
..\%__SRC%\bin\tralay %_DEST%\bin\tralay
..\%__SRC%\bin\ulfconv %_DEST%\bin\ulfconv ..\%__SRC%\bin\ulfconv %_DEST%\bin\ulfconv
..\%__SRC%\class\FCFGMerge.jar %_DEST%\bin\FCFGMerge.jar ..\%__SRC%\class\FCFGMerge.jar %_DEST%\bin\FCFGMerge.jar
..\%__SRC%\class\HelpIndexerTool.jar %_DEST%\bin\HelpIndexerTool.jar ..\%__SRC%\class\HelpIndexerTool.jar %_DEST%\bin\HelpIndexerTool.jar
..\%__SRC%\class\jpropex\jpropex.jar %_DEST%\bin\jpropex.jar
..\%__SRC%\bin\HelpLinker %_DEST%\bin\HelpLinker ..\%__SRC%\bin\HelpLinker %_DEST%\bin\HelpLinker
..\%__SRC%\bin\HelpCompiler %_DEST%\bin\HelpCompiler ..\%__SRC%\bin\HelpCompiler %_DEST%\bin\HelpCompiler
..\%__SRC%\bin\HelpCompiler.exe %_DEST%\bin\HelpCompiler.exe ..\%__SRC%\bin\HelpCompiler.exe %_DEST%\bin\HelpCompiler.exe
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment