Free Support Forum - groupdocs.com

Not supported culture


#1

Hello,

we try to use GroupsDoc.Viewer for file conversion only.
If we have an environment “language - english, locale - german” (“en-DE”), the got an exception:
com.groupdocs.viewer.internal.c.a.ms.System.ArgumentException: Culture Name: en-DE is not a supported culture
at com.groupdocs.viewer.internal.c.a.ms.System.Globalization.CultureInfo.findIdByName(Unknown Source)
at com.groupdocs.viewer.internal.c.a.ms.System.Globalization.CultureInfo.(Unknown Source)
at com.groupdocs.viewer.internal.c.a.ms.System.Globalization.CultureInfo.fromJava(Unknown Source)
at com.groupdocs.viewer.internal.c.a.ms.System.Threading.Thread.getCurrentCulture(Unknown Source)
at com.groupdocs.viewer.internal.c.a.ms.System.Globalization.CultureInfo.getCurrentCulture(Unknown Source)
at com.groupdocs.viewer.internal.c.a.ms.System.StringExtensions.indexOf(Unknown Source)
at com.groupdocs.viewer.internal.c.a.ms.System.StringExtensions.contains(Unknown Source)
at com.groupdocs.viewer.domain.FileDescription.bZ(Unknown Source)

Recommended solution:
CultureInfo cultureInfo = new CultureInfo(“en-Us”);
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config, cultureInfo);

dosn’t work


#2

@valentinz,

You are getting this message because the API only supports the following cultures:

  • en-Us
  • pt-PT
  • ru-RU

In case your desired culture is not listed above, you can create and use your own. For details, please visit this documentation article.

We have verified this solution and it is working as expected.


#3

Unforunatelly, we have other results:

ViewerConfig config = new ViewerConfig();
config.setStoragePath(filePath);
CultureInfo cultureInfo = new CultureInfo(“ru-RU”);
log.info(“cultureInfo: {}”, cultureInfo);

ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config cultureInfo);
PdfFileOptions pdfFileOptions = new PdfFileOptions();

FileContainer container = null;
InputStream input = htmlHandler.getPdfFile(inputStream customFile.getFileName() pdfFileOptions);
log.info(“container.getStream().available()) {}”, container.getStream().available());

and we got:
7:39:41 [http-nio-8383-exec-10] INFO d.x.w.u.f.ConvertService - cultureInfo: ru-RU
17:39:41 [http-nio-8383-exec-10] INFO d.x.w.u.f.ConvertService - getInputStreamFromCustomFile, CacheFilePath: /Users/valentin/tempCache/Einkauf/JDJhJDEwJGp4a2NrWDdjc3VxZk42R3BrYS9oZy5RcWNUYU5DTTZQSS42OHpEbmtJU3FLQ3dYLms1V0Eu
17:39:41 [http-nio-8383-exec-10] ERROR d.x.w.u.f.ConvertService - getConvertedToPdfInputStream, IO error: Culture Name: en-DE is not a supported culture, null
17:39:41 [http-nio-8383-exec-10] ERROR d.x.w.u.f.ConvertService - getConvertedToPdfInputStream, error:
com.groupdocs.viewer.internal.c.a.ms.System.ArgumentException: Culture Name: en-DE is not a supported culture
at com.groupdocs.viewer.internal.c.a.ms.System.Globalization.CultureInfo.findIdByName(Unknown Source)
at com.groupdocs.viewer.internal.c.a.ms.System.Globalization.CultureInfo.(Unknown Source)
at com.groupdocs.viewer.internal.c.a.ms.System.Globalization.CultureInfo.fromJava(Unknown Source)
at com.groupdocs.viewer.internal.c.a.ms.System.Threading.Thread.getCurrentCulture(Unknown Source)
at com.groupdocs.viewer.internal.c.a.ms.System.Globalization.CultureInfo.getCurrentCulture(Unknown Source)
at com.groupdocs.viewer.internal.c.a.ms.System.StringExtensions.indexOf(Unknown Source)
at com.groupdocs.viewer.internal.c.a.ms.System.StringExtensions.contains(Unknown Source)
at com.groupdocs.viewer.domain.FileDescription.bZ(Unknown Source)
at com.groupdocs.viewer.domain.FileDescription.(Unknown Source)
at com.groupdocs.viewer.handler.input.a.a.getFileDescription(Unknown Source)
at com.groupdocs.viewer.handler.ViewerHandler.a(Unknown Source)
at com.groupdocs.viewer.handler.ViewerHandler.a(Unknown Source)
at com.groupdocs.viewer.handler.ViewerHandler.getPdfFile(Unknown Source)
at de.xm.workbasket.utils.formatconversions.ConvertService.getConvertedToPdfInputStream(ConvertService.java:53)

A code example from documentation article cannot be compiled with
‘com.groupdocs:groupdocs-viewer:19.3’


#4

@valentinz,

In the source code that you have shared above, I noticed that you haven’t set the folder’s path in the configurations which will contain your LocalizedStrings-ru-RU.xml file. Please set the locale folder’s path using:

config.setLocalesPath("D://locales//"); 
// place LocalizedStrings-ru-RU.xml file inside locales folder

Furthermore, the error message you have shared is contradicting with the source code since you have set ru-RU as CultureInfo in the code but the error message says: “Culture Name: en-DE is not a supported culture”. Therefore, please verify that you are using the correct source code. If you still face the issue, please create and share with us the sample console application that can be used to reproduce the issue that you are facing.

We have verified the code sample for the custom locale and it is working fine with v19.3.


#5

Very simple code:

package de.xm.simplegroupdocs;

import com.groupdocs.viewer.config.ViewerConfig;
import com.groupdocs.viewer.domain.containers.FileContainer;
import com.groupdocs.viewer.domain.options.PdfFileOptions;
import com.groupdocs.viewer.handler.ViewerHtmlHandler;
import com.groupdocs.viewer.licensing.License;
import com.groupdocs.viewer.utils.CultureInfo;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;

public class SimpleGroupDocsTest {

public static void main(String[] args) {

System.out.println(“SimpleGroupDocs started :)”);
SimpleGroupDocsTest simpleGroupDocs = new SimpleGroupDocsTest();
simpleGroupDocs.setLicense();
simpleGroupDocs.convertToPdf();
}

private void convertToPdf() {
try {
File sourceFile = new File("./FilesSource/MARBIBM.TIF");

System.out.println("sourceFile: " + sourceFile);
System.out.println("sourceFile readable: " + sourceFile.canRead());

ViewerConfig config = new ViewerConfig();

File localizedStringsFile = new File("./FilesGroupDocs/LocalizedStrings-ru-RU.xml");
System.out.println(“localizedStringsFile: " + sourceFile);
System.out.println(“localizedStringsFile readable: " + sourceFile.canRead());
System.out.println(“localizedStringsFile length: " + localizedStringsFile.length());
config.setLocalesPath(”./FilesGroupDocs/LocalizedStrings-ru-RU.xml”);
config.setStoragePath(”./FilesSource");
CultureInfo cultureInfo = new CultureInfo(“ru-RU”);

System.out.println("\ncultureInfo: " + cultureInfo);

ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config, cultureInfo);
PdfFileOptions pdfFileOptions = new PdfFileOptions();

FileContainer container = null;
InputStream inputStream = new FileInputStream(sourceFile);
container = htmlHandler.getPdfFile(inputStream, sourceFile.getName(), pdfFileOptions);
System.out.println("container.getStream().available()): " + container.getStream().available());

Files.copy(container.getStream(), Paths.get("./FilesConverted", “ConvertedFile.pdf”), StandardCopyOption.REPLACE_EXISTING);
File resultFile = new File(Paths.get("./FilesConverted", “ConvertedFile.pdf”).toString());
System.out.println("resultFile: " + resultFile);
System.out.println("resultFile readable: " + resultFile.canRead());
System.out.println("resultFile length: " + resultFile.length());

} catch (Exception e) {
System.out.println("Error: " + e.getMessage() + ", cause: " + e.getCause());
}
}

private void setLicense() {
try {
String licenseFilePath = “./FilesGroupDocs/GroupDocs.Viewer.lic”;
License license = new License();
license.setLicense(licenseFilePath);
} catch (Throwable throwable) {
System.out.println(“Can not verify Viewer license!”);
}
}
}

It works with locale en-US:

SimpleGroupDocs started :slight_smile:
sourceFile: ./FilesSource/MARBIBM.TIF
sourceFile readable: true
localizedStringsFile: ./FilesSource/MARBIBM.TIF
localizedStringsFile readable: true
localizedStringsFile length: 1171

cultureInfo: ru-RU
container.getStream().available()): 319843
resultFile: ./FilesConverted/ConvertedFile.pdf
resultFile readable: true
resultFile length: 319843

If we change locale to en-DE:

SimpleGroupDocs started :slight_smile:
sourceFile: ./FilesSource/MARBIBM.TIF
sourceFile readable: true
localizedStringsFile: ./FilesSource/MARBIBM.TIF
localizedStringsFile readable: true
localizedStringsFile length: 1171

cultureInfo: ru-RU
Error: Culture Name: en-DE is not a supported culture, cause: null

Process finished with exit code 0

What is wrong in code?


#6

@valentinz,

Thanks for providing the complete source code. We are able to reproduce your reported behavior for the en-DE culture even when using the custom localized strings. We have logged it in our Issue Tracking System (ID: VIEWERJAVA-1947) for further investigation. We shall keep you informed as soon as we have any updates for you.


#7

Thanks for response,
we have the same problem with GroupDocs.Conversion too


#8

@valentinz,

In that case, I would suggest you to please create a separate topic in GroupDocs.Conversion Product Family category.


#9

@valentinz,

The issue you have faced earlier regarding en-DE culture has been fixed. The fix will be packaged with the upcoming version of GroupDocs.Viewer for Java which is expected to be released in the current month. As soon as the release is on-board, we shall notify you here.


#10

thank you very much, very curious


#11

@valentinz,

You are welcome.


#12

@valentinz,

The issue you have faced earlier (logged as VIEWERJAVA-1947) has been fixed in this release.


#13

Thank you, i’ll check it


#14

Hi, I don’t found issue VIEWERJAVA-1947 in current release 19.8.
The error remained unchanged - I checked it with the code that I sent.
I just found the promise that localization will be removed in version 19.10

Code:
private void convertToPdf() {
try {
File sourceFile = new File("./FilesSource/MARBIBM.TIF");

        System.out.println("Locale.getDefault(): " + Locale.getDefault());
        System.out.println("sourceFile: " + sourceFile);
        System.out.println("sourceFile readable: " + sourceFile.canRead());

        ViewerConfig config = new ViewerConfig();

        File localizedStringsFile = new File("./FilesGroupDocs/LocalizedStrings-en-US.xml");
        System.out.println("localizedStringsFile: " + localizedStringsFile);
        System.out.println("localizedStringsFile readable: " + sourceFile.canRead());
        System.out.println("localizedStringsFile length: " + localizedStringsFile.length());
        config.setLocalesPath(localizedStringsFile.getAbsolutePath());
        config.setStoragePath("./FilesSource");

        System.out.println("\nLocale.getDefault: " + Locale.getDefault());
        CultureInfo cultureInfo = new CultureInfo("en-US");

        System.out.println("\ncultureInfo: " + cultureInfo);
        System.out.println("\nLocale.getDefault: " + Locale.getDefault());

        ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config, cultureInfo);
        PdfFileOptions pdfFileOptions = new PdfFileOptions();

        FileContainer container = null;
        InputStream inputStream = new FileInputStream(sourceFile);
        container = htmlHandler.getPdfFile(inputStream, sourceFile.getName(), pdfFileOptions);
        System.out.println("container.getStream().available()): " + container.getStream().available());

        Files.copy(container.getStream(), Paths.get("./FilesConverted", "ConvertedFile.pdf"), StandardCopyOption.REPLACE_EXISTING);
        File resultFile = new File(Paths.get("./FilesConverted", "ConvertedFile.pdf").toString());
        System.out.println("resultFile: " + resultFile);
        System.out.println("resultFile readable: " + resultFile.canRead());
        System.out.println("resultFile length: " + resultFile.length());

    } catch (Exception e) {
        System.out.println("Error: " + e.getMessage() + ", cause: " + e.getCause());
        e.printStackTrace();
    }
}

Console output:
/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/bin/java “-javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=50317:/Applications/IntelliJ IDEA.app/Contents/bin” -Dfile.encoding=UTF-8 -classpath /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/ext/openjsse.jar:/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/lib/tools.jar:/Users/valentinschuravlov/Work/IntelliJ_WS/SimpleGroupDocs/out/production/SimpleGroupDocs:/Users/valentinschuravlov/Work/IntelliJ_WS/SimpleGroupDocs/libs/groupdocs-conversion-19.6.2.jar:/Users/valentinschuravlov/Work/IntelliJ_WS/SimpleGroupDocs/libs/slf4j-api-1.7.26.jar:/Users/valentinschuravlov/Work/IntelliJ_WS/SimpleGroupDocs/libs/groupdocs-viewer-19.8.jar de.xm.simplegroupdocs.SimpleGroupDocsTest
SimpleGroupDocs started :slight_smile:
Locale.getDefault(): en_DE
sourceFile: ./FilesSource/MARBIBM.TIF
sourceFile readable: true
localizedStringsFile: ./FilesGroupDocs/LocalizedStrings-en-US.xml
localizedStringsFile readable: true
localizedStringsFile length: 1171

Locale.getDefault: en_DE

cultureInfo: com.groupdocs.viewer.utils.CultureInfo@6ad5c04e

Locale.getDefault: en_DE
Error: Culture Name: en-DE is not a supported culture, cause: null
class com.groupdocs.viewer.internal.c.a.ms.System.ArgumentException: Culture Name: en-DE is not a supported culture
com.groupdocs.viewer.internal.c.a.ms.System.Globalization.CultureInfo.findIdByName(Unknown Source)
com.groupdocs.viewer.internal.c.a.ms.System.Globalization.CultureInfo.(Unknown Source)
com.groupdocs.viewer.internal.c.a.ms.System.Globalization.CultureInfo.fromJava(Unknown Source)
com.groupdocs.viewer.internal.c.a.ms.System.Threading.Thread.getCurrentCulture(Unknown Source)
com.groupdocs.viewer.internal.c.a.ms.System.Globalization.CultureInfo.getCurrentCulture(Unknown Source)
com.groupdocs.viewer.internal.c.a.ms.System.StringExtensions.indexOf(Unknown Source)
com.groupdocs.viewer.internal.c.a.ms.System.StringExtensions.contains(Unknown Source)
com.groupdocs.viewer.domain.FileDescription.cd(Unknown Source)
com.groupdocs.viewer.domain.FileDescription.(Unknown Source)
com.groupdocs.viewer.handler.input.a.a.getFileDescription(Unknown Source)
com.groupdocs.viewer.handler.ViewerHandler.a(Unknown Source)
com.groupdocs.viewer.handler.ViewerHandler.a(Unknown Source)
com.groupdocs.viewer.handler.ViewerHandler.getPdfFile(Unknown Source)
de.xm.simplegroupdocs.SimpleGroupDocsTest.convertToPdf(SimpleGroupDocsTest.java:64)
de.xm.simplegroupdocs.SimpleGroupDocsTest.main(SimpleGroupDocsTest.java:32)
at com.groupdocs.viewer.internal.c.a.ms.System.Globalization.CultureInfo.findIdByName(Unknown Source)
at com.groupdocs.viewer.internal.c.a.ms.System.Globalization.CultureInfo.(Unknown Source)
at com.groupdocs.viewer.internal.c.a.ms.System.Globalization.CultureInfo.fromJava(Unknown Source)
at com.groupdocs.viewer.internal.c.a.ms.System.Threading.Thread.getCurrentCulture(Unknown Source)
at com.groupdocs.viewer.internal.c.a.ms.System.Globalization.CultureInfo.getCurrentCulture(Unknown Source)
at com.groupdocs.viewer.internal.c.a.ms.System.StringExtensions.indexOf(Unknown Source)
at com.groupdocs.viewer.internal.c.a.ms.System.StringExtensions.contains(Unknown Source)
at com.groupdocs.viewer.domain.FileDescription.cd(Unknown Source)
at com.groupdocs.viewer.domain.FileDescription.(Unknown Source)
at com.groupdocs.viewer.handler.input.a.a.getFileDescription(Unknown Source)
at com.groupdocs.viewer.handler.ViewerHandler.a(Unknown Source)
at com.groupdocs.viewer.handler.ViewerHandler.a(Unknown Source)
at com.groupdocs.viewer.handler.ViewerHandler.getPdfFile(Unknown Source)
at de.xm.simplegroupdocs.SimpleGroupDocsTest.convertToPdf(SimpleGroupDocsTest.java:64)
at de.xm.simplegroupdocs.SimpleGroupDocsTest.main(SimpleGroupDocsTest.java:32)

Process finished with exit code 0


#15

@valentinz,

We have verified the fix and the issue is resolved in v19.8. For reference, please download this sample plug and play application that uses your code with little modifications.

Yes, GroupDocs.Viewer no longer provides localization support and therefore, the methods related to this feature have been marked as deprecated and will be removed in v19.10. For details, please see the release notes of v19.8.


#16

Unfortunately I have the same:
Screenshot 2019-08-14 at 10.10.17.png (226.0 KB)

Have you tested with settings en-DE?
Screenshot 2019-08-14 at 10.11.31.png (129.2 KB)

System.out.println("Locale.getDefault: " + Locale.getDefault());


#17

@valentinz,

We noticed that the issue persists if the default locale of the JVM is set to the “en_DE”, however, if we change the default locale to “en_US” using the Locale.setDefault() method then the exception doesn’t occur. Please try to add the following code before GroupDocs.Viewer’s code in the sample application that we have provided you in the previous reply:

Locale usLocale = new Locale("en", "US");
Locale.setDefault(usLocale);
```

We have also logged this behavior against the ticket VIEWERJAVA-1947 for further investigation. You can use the workaround shared above until we get any further updates.


#18

Thank you, nice workaround :slight_smile:


#19

@valentinz,

You’re welcome.


#20

@valentinz,

The issue you have faced earlier, logged as VIEWERJAVA-1947, has been fixed in v19.8.1. To avoid the exception, please use CultureInfo.setDefault(“en”, “DE”) in your code as shown in the following code sample:

// Viewer's configuration
ViewerConfig config = new ViewerConfig();
config.setStoragePath("./storage");
config.setLocalesPath("./locales");
CultureInfo.setDefault("en", "DE");

// Set culture en-DE
CultureInfo cultureInfo = new CultureInfo("en-DE"); 

// Create ViewerHtmlHandler (or ViewerImageHandler for image-based rendering)
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config, cultureInfo);