Norwegian Nynorsk translation + a few bugfixes

git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@75 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
henrikjust 2010-10-27 09:25:35 +00:00
parent e4eafbf87c
commit b415705e47
15 changed files with 338 additions and 24 deletions

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.2 (2010-10-13)
* Version 1.2 (2010-10-27)
*
*/
@ -33,7 +33,7 @@ public class ConverterFactory {
// Version information
private static final String VERSION = "1.1.5";
private static final String DATE = "2010-10-13";
private static final String DATE = "2010-10-27";
/** Return the Writer2LaTeX version in the form
* (major version).(minor version).(patch level)<br/>

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.2 (2010-05-09)
* Version 1.2 (2010-10-27)
*
*/
@ -590,6 +590,14 @@ public class OfficeReader {
}
/** <p>Is there a reference to this note id?
* @param sId the id of the note
* @return true if there is a reference
*/
public boolean hasNoteRefTo(String sId) {
return footnoteRef.contains(sId) || endnoteRef.contains(sId);
}
/** <p>Is there a reference to this footnote id?
* @param sId the id of the footnote
* @return true if there is a reference

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2009 by Henrik Just
* Copyright: 2002-2010 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.2 (2009-06-05)
* Version 1.2 (2010-10-27)
*
*/
@ -89,11 +89,25 @@ public class ExportNameCollection{
}
}
String sExportName=outbuf.toString();
// the result may exist in the collecion; add a's at the end
while (exportNames.containsValue(sExportName)){
sExportName+="a";
if (sExportName.length()==0) {
// Do not accept empty export names
sExportName = "qwerty";
}
if (!exportNames.containsValue(sExportName)) {
// Everything's fine, we can use the stripped name directly
exportNames.put(sName,sExportName);
}
else {
// Otherwise add letters at the end until a unique export name is found
int i=1;
while (true) {
String sSuffix = Misc.int2alph(i++, false);
if (!exportNames.containsValue(sExportName+sSuffix)) {
exportNames.put(sName,sExportName+sSuffix);
break;
}
}
}
exportNames.put(sName,sExportName);
}
public String getExportName(String sName) {

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.2 (2010-05-17)
* Version 1.2 (2010-10-27)
*
*/
@ -34,6 +34,7 @@ import java.io.UnsupportedEncodingException;
import java.lang.Math;
import java.net.URLEncoder;
import java.net.URLDecoder;
import java.util.Arrays;
//import java.util.Hashtable;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@ -53,6 +54,7 @@ public class Misc{
}
public static final String int2roman(int number) {
assert number>0; // Only works for positive numbers!
StringBuffer roman=new StringBuffer();
while (number>=1000) { roman.append('m'); number-=1000; }
if (number>=900) { roman.append("cm"); number-=900; }
@ -79,8 +81,26 @@ public class Misc{
}
public static final String int2alph(int number, boolean bLetterSync) {
// TODO: Handle overflow/lettersync
return new Character((char) (number+96)).toString();
assert number>0; // Only works for positive numbers!
if (bLetterSync) {
char[] chars = new char[(number-1)/26+1]; // Repeat the character this number of times
Arrays.fill(chars, (char) ((number-1) % 26+97)); // Use this character
return String.valueOf(chars);
}
else {
int n=number-1;
// Least significant digit is special because a is treated as zero here!
int m = n % 26;
String sNumber = Character.toString((char) (m+97));
n = (n-m)/26;
// For the more significant digits, a is treated as one!
while (n>0) {
m = n % 26; // Calculate new least significant digit
sNumber = ((char) (m+96))+sNumber;
n = (n-m)/26;
}
return sNumber;
}
}
public static final String int2Alph(int number, boolean bLetterSync) {

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.2 (2010-06-03)
* Version 1.2 (2010-10-27)
*
*/
@ -165,6 +165,20 @@ public class L10n {
case DOCUMENT: return "Dokument";
}
}
if (sLocale.startsWith("nn")) { // nynorsk
switch (nString) {
case UP: return "Opp";
case FIRST : return "F\u00f8rste";
case PREVIOUS : return "Forrige";
case NEXT : return "Neste";
case LAST : return "Siste";
case CONTENTS : return "Innhald";
case INDEX : return "Register";
case HOME : return "Heim";
case DIRECTORY: return "Mappe";
case DOCUMENT: return "Dokument";
}
}
if (sLocale.startsWith("pl")) { // polish
switch (nString) {
case UP: return "W g\u00f3r\u0119";

View file

@ -1717,7 +1717,7 @@ public class TextConverter extends ConverterHelper {
private void handleSequence(Node onode, Node hnode) {
// Use current value, but turn references into hyperlinks
String sName = Misc.getAttribute(onode,XMLString.TEXT_REF_NAME);
if (sName!=null && !bInToc) {
if (sName!=null && !bInToc && ofr.hasSequenceRefTo(sName)) {
Element anchor = converter.createTarget("seq"+sName);
hnode.appendChild(anchor);
traversePCDATA(onode,anchor);
@ -1742,7 +1742,7 @@ public class TextConverter extends ConverterHelper {
}
private void handleSequenceRef(Node onode, Node hnode) {
createReference(onode,hnode,"seq");
createReference(onode,hnode,"seq");
}
private void handleNoteRef(Node onode, Node hnode) {
@ -1751,13 +1751,13 @@ public class TextConverter extends ConverterHelper {
private void handleReferenceMark(Node onode, Node hnode) {
String sName = Misc.getAttribute(onode,XMLString.TEXT_NAME);
if (sName!=null && !bInToc) {
if (sName!=null && !bInToc && ofr.hasReferenceRefTo(sName)) {
hnode.appendChild(converter.createTarget("ref"+sName));
}
}
private void handleReferenceRef(Node onode, Node hnode) {
createReference(onode,hnode,"ref");
createReference(onode,hnode,"ref");
}
private void handleBookmark(Node onode, Node hnode) {
@ -1765,7 +1765,9 @@ public class TextConverter extends ConverterHelper {
String sName = Misc.getAttribute(onode,XMLString.TEXT_NAME);
if (sName!=null && !bInToc) {
hnode.appendChild(converter.createTarget(sName));
hnode.appendChild(converter.createTarget("bkm"+sName));
if (ofr.hasBookmarkRefTo(sName)) {
hnode.appendChild(converter.createTarget("bkm"+sName));
}
}
}