CSJCurrent en:Language Resources: Unterschied zwischen den Versionen
(Imported from text file) |
(Edited by replacement maintenance script.) |
||
Zeile 3: | Zeile 3: | ||
----- | ----- | ||
The Cryptshare Server can provide the '''Client''' with the language resources contained in the [ | The Cryptshare Server can provide the '''Client''' with the language resources contained in the [[CSSCurrent_en:Language Packages|Language Packages]] that have been installed on the server. These [[CSSCurrent_en:Language Packages|Language Packages]] can then be used for a user interface on client side, for instance. | ||
= Available Languages = | = 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. | 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. | ||
Zeile 30: | Zeile 30: | ||
} | } | ||
= Downloading a Language Pack File = | = Downloading a Language Pack File = | ||
Now that you know which [ | Now that you know which [[CSSCurrent_en:Language Packages|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. | ||
{{InfoBox|title=Language Pack Base Name|content=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: | {{InfoBox|title=Language Pack Base Name|content=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: | ||
Aktuelle Version vom 9. März 2022, 07:41 Uhr
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, Paths.get("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.getVersion(); ZonedDateTime 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.
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, Paths.get("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) { try (FileOutputStream outStream = new FileOutputStream("lang.xml")) { outStream.write(langFileBytes); } catch (Exception e) { e.printStackTrace(); } }