[chronojump] If unicode doesn not work on Windows, don't translate (80% done)
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] If unicode doesn not work on Windows, don't translate (80% done)
- Date: Fri, 18 Dec 2015 01:10:11 +0000 (UTC)
commit 5ed1ed1c01656533cfce4ae65a65d2ca5b41736d
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Dec 18 02:08:06 2015 +0100
If unicode doesn not work on Windows, don't translate (80% done)
encoder/graph.R | 45 ++++++++++++++++++++++++++++++++++-----------
1 files changed, 34 insertions(+), 11 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index 7692dd7..3ade8b7 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -77,23 +77,42 @@ colSpeed="springgreen3"; colForce="blue2"; colPower="tomato2" #colors
#colSpeed="black"; colForce="black"; colPower="black" #black & white
cols=c(colSpeed,colForce,colPower); lty=rep(1,3)
+unicodeWorks = FALSE
+
+#needed for some windows machines
+checkUnicodeWorks <- function()
+{
+ tryCatch (
+ {
+ plot(1,1, xlab="some unicode stuff")
+ return(TRUE)
+ },
+ error=function(cond) {
+ message(cond)
+ return(FALSE) }
+ )
+}
+
#translateToPrint An expression is returned andcan only be printed. Don't do operations
#Important: An expression is returned because is the best way to ahndle unicode on windows
#take care not to do operations with this. Just print it
-translateToPrint <- function(englishWord) {
+translateToPrint <- function(englishWord)
+{
+ if(! unicodeWorks)
+ return (englishWord) #unicode is not working, return english word
+
if(length(Translated[which(English == englishWord)]) == 0)
return (englishWord) #not found, return english word
- else {
- myWord = Translated[which(English == englishWord)]
-
- #Needed conversion for Windows:
- #unicoded titles arrive here like this "\\", convert to "\", as this is difficult, do like
this:
- #http://stackoverflow.com/a/17787736
- myWord = parse(text = paste0("'", myWord, "'"))
-
- return(myWord)
- }
+
+ myWord = Translated[which(English == englishWord)]
+
+ #Needed conversion for Windows:
+ #unicoded titles arrive here like this "\\", convert to "\", as this is difficult, do like this:
+ #http://stackoverflow.com/a/17787736
+ myWord = parse(text = paste0("'", myWord, "'"))
+
+ return(myWord)
}
translateVector <- function(englishVector) {
@@ -2201,6 +2220,10 @@ loadLibraries <- function(os) {
doProcess <- function(options)
{
op <- assignOptions(options)
+
+ #if unicodeWorks, then translations will be done
+ #<<- to assign to a global variable
+ unicodeWorks <<- checkUnicodeWorks()
print(c("1 Title=",op$Title))
#unicoded titles arrive here like this "\\", convert to "\", as this is difficult, do like this:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]