Skip to end of metadata
Go to start of metadata


 

The Cryptshare Server can provide the Client with the language resources contained in the Language Packages that have been installed on the server. These Language Packages can then be used for a user interface on client side, for instance.

Available Languages

You can check what languages are available on the server using the Client's method requestLanguagePacks(). It will return a list of LanguagePack objects containing information about each installed language pack. You can then use the data from this list to request a specific language pack file for download.

Example: Requesting a List of Available Languages
// First create the Client instance
// Create a WebServiceUri for your Cryptshare Server 
WebServiceUri serviceUri = new WebServiceUri("https://cryptshare.server.com");
 
// Create a CryptshareConnection instance for your WebServiceUri
CryptshareConnection connection = new CryptshareConnection(serviceUri);
 
// Create the Client instance with the sender's email address, 
// the CryptshareConnection, and the path to the verification store.
Client client = new Client("sender_email@server.com", connection, "C:\temp");

// Now we can request the list of installed languages
List<LanguagePack> languagePackList = client.requestLanguagePacks();

for (LanguagePack languagePack : languagePackList) {
	Locale locale = languagePack.getLocale();
	String version = languagePack.getLanguagePackVersion();
	long lastUpdate = languagePack.getLastUpdate();
	System.out.println("Language pack language = " + locale.getLanguage() + 
			" with version = " + version + " last updated at " + lastUpdate);
}

Downloading a Language Pack File

Now that you know which  Language Packages are available on the server, you can download a specific language pack file using the Client's method requestLanguagePackFile(String,Locale). The method requires the base name of the actual language pack file on the server as the first parameter and the desired Locale as the second parameter.

Language Pack Base Name

The base name of the actual language pack file on the server is just the file name, minus the language or country information. For example, if you have the language pack file "lang_en_GB.xml" installed on the server, the base name for that language pack file would be "lang.xml". So you would request this particular language pack file, using the following method call:

Locale locale = Locale.UK;
byte[] langFileBytes = client.requestLanguagePackFile("lang.xml", locale);

 

Here is a complete example of how to request a specific language pack file:

Example: Downloading a Language Pack File
// First create the Client instance
// Create a WebServiceUri for your Cryptshare Server 
WebServiceUri serviceUri = new WebServiceUri("https://cryptshare.server.com");
 
// Create a CryptshareConnection instance for your WebServiceUri
CryptshareConnection connection = new CryptshareConnection(serviceUri);
 
// Create the Client instance with the sender's email address, 
// the CryptshareConnection, and the path to the verification store.
Client client = new Client("sender_email@server.com", connection, "C:\temp");

// Get the list of available languages
List<LanguagePack> languagePackList = client.requestLanguagePacks();

// Now we can request the download of a specific language pack file, where
// the first parameter of the method is the base name of the physical language 
// pack file on the server, and the second parameter is the desired Locale.
// For this example, we will just download the first language pack from the
// list of available languages.
 byte[] langFileBytes = client.requestLanguagePackFile("lang.xml", 
										languagePackList.get(0).getLocale());

// save the file to the current directory on our local disk 
if (langFileBytes != null) {
	FileOutputStream outStream = null;
    try {
    	outStream = new FileOutputStream("lang.xml");
        outStream.write(langFileBytes);        
    }
    catch (Exception e) {
    	e.printStackTrace();
    }
    finally {
    	try {
        	outStream.close();
        }
        catch (Exception e) {}
    }
}

 


  • No labels