c82c051f296abce2bec1dbdbb43d6ef85f235c47
API/CodeSamples/Language.md
| ... | ... | @@ -0,0 +1,132 @@ |
| 1 | +#Language |
|
| 2 | + |
|
| 3 | +[[_TOC_]] |
|
| 4 | + |
|
| 5 | +##About |
|
| 6 | + |
|
| 7 | +The Language setting will change the language used within Izenda reports. This can be used to localize the reporting section of your application to your users' cultural dialect. Currently, Izenda reports only supports a limited amount of languages as each additional resource file does take development work. Support for new languages is added based on demand. Setting a language will change interface buttons, labels, and links. This will not change dynamic data such as report names, categories, or information from the database. |
|
| 8 | + |
|
| 9 | +**Default Value:** AdHocLanguage.English |
|
| 10 | + |
|
| 11 | +####Global.asax (C♯) |
|
| 12 | + |
|
| 13 | +``` csharp |
|
| 14 | +//main class: inherits DatabaseAdHocConfig or FileSystemAdHocConfig |
|
| 15 | +public class CustomAdHocConfig : Izenda.AdHoc.DatabaseAdHocConfig |
|
| 16 | +{ |
|
| 17 | + // Configure settings |
|
| 18 | + // Add custom settings after setting the license key and connection string by overriding the ConfigureSettings() method |
|
| 19 | + public static void InitializeReporting() { |
|
| 20 | + //Check to see if we've already initialized. |
|
| 21 | + if (HttpContext.Current.Session == null || HttpContext.Current.Session["ReportingInitialized"] != null) |
|
| 22 | + return; |
|
| 23 | + AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE"; |
|
| 24 | + AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE"; |
|
| 25 | + Izenda.AdHoc.AdHocSettings.AdHocConfig = new CustomAdHocConfig(); |
|
| 26 | + AdHocSettings.Language = AdHocLanguage.French; //The relevant setting |
|
| 27 | + HttpContext.Current.Session["ReportingInitialized"] = true; |
|
| 28 | + } |
|
| 29 | +} |
|
| 30 | +``` |
|
| 31 | +##Global.asax (VB.NET) |
|
| 32 | + |
|
| 33 | +```visualbasic |
|
| 34 | +'main class: inherits DatabaseAdHocConfig or FileSystemAdHocConfig |
|
| 35 | +Public Class CustomAdHocConfig |
|
| 36 | + Inherits Izenda.AdHoc.DatabaseAdHocConfig |
|
| 37 | + |
|
| 38 | + Shared Sub InitializeReporting() |
|
| 39 | + 'Check to see if we've already initialized |
|
| 40 | + If HttpContext.Current.Session Is Nothing OrElse HttpContext.Current.Session("ReportingInitialized") IsNot Nothing Then |
|
| 41 | + Return |
|
| 42 | + 'Initialize System |
|
| 43 | + AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE" |
|
| 44 | + AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE" |
|
| 45 | + Izenda.AdHoc.AdHocSettings.AdHocConfig = New CustomAdHocConfig() |
|
| 46 | + AdHocSettings.ExportLimit = 100000 'The relevant setting |
|
| 47 | + HttpContext.Current.Session("ReportingInitialized") = True |
|
| 48 | + End Sub |
|
| 49 | +End Class |
|
| 50 | +``` |
|
| 51 | + |
|
| 52 | +####Per Country By Tenant(Customer) ID |
|
| 53 | + |
|
| 54 | +```csharp |
|
| 55 | +public static void InitializeReporting() |
|
| 56 | +{ |
|
| 57 | + switch ( GetUserCountry()){ |
|
| 58 | + case "USA": |
|
| 59 | + case "UK": |
|
| 60 | + case "Ireland": |
|
| 61 | + AdHocSettings.Language = AdHocLanguage.English; |
|
| 62 | + break; |
|
| 63 | + case "France": |
|
| 64 | + AdHocSettings.Language = AdHocLanguage.French; |
|
| 65 | + break; |
|
| 66 | + case "Spain": |
|
| 67 | + case "Mexico": |
|
| 68 | + case "Venezuela": |
|
| 69 | + case "Argentina": |
|
| 70 | + case "Brazil": |
|
| 71 | + AdHocSettings.Language = AdHocLanguage.Spanish; |
|
| 72 | + break; |
|
| 73 | + case "Germany": |
|
| 74 | + case "Austria": |
|
| 75 | + case "Poland": |
|
| 76 | + case "Switzerland": |
|
| 77 | + AdHocSettings.Language = AdHocLanguage.German; |
|
| 78 | + break; |
|
| 79 | + case "Russia": |
|
| 80 | + AdHocSettings.Language = AdHocLanguage.Russian; |
|
| 81 | + break; |
|
| 82 | + case "Japan": |
|
| 83 | + AdHocSettings.Language = AdHocLanguage.Japanese; |
|
| 84 | + break; |
|
| 85 | + case "China": |
|
| 86 | + AdHocSettings.Language = AdHocLanguage.ChinesePeoplesRepublicofChina; |
|
| 87 | + break; |
|
| 88 | + case "Taiwan": |
|
| 89 | + AdHocSettings.Language = AdHocLanguage.ChineseTaiwan; |
|
| 90 | + break; |
|
| 91 | + case "Italy": |
|
| 92 | + AdHocSettings.Language = AdHocLanguage.Italian; |
|
| 93 | + break; |
|
| 94 | + case "South Korea": |
|
| 95 | + case "North Korea": |
|
| 96 | + case "Korea": |
|
| 97 | + AdHocSettings.Language = AdHocLanguage.Korean; |
|
| 98 | + break; |
|
| 99 | + case "Belgium": |
|
| 100 | + AdHocSettings.Language = AdHocLanguage.Dutch; |
|
| 101 | + break; |
|
| 102 | + default: |
|
| 103 | + AdHocSettings.Language = AdHocLanguage.English; |
|
| 104 | + break; |
|
| 105 | + } |
|
| 106 | +} |
|
| 107 | + |
|
| 108 | +public static string GetUserCountry() { |
|
| 109 | + String sql = string.Format(@"SELECT [dbo].[Customers].[Country] FROM [dbo].[Customers] WHERE [dbo].[Customers].[CustomerID] = '{0}'", AdHocSettings.CurrentUserTenantId); |
|
| 110 | + SqlCommand cmd = new SqlCommand(sql); |
|
| 111 | + DataSet ds = new DataSet(); |
|
| 112 | + using (SqlConnection connection = new SqlConnection(AdHocSettings.SqlServerConnectionString)) { |
|
| 113 | + connection.Open(); |
|
| 114 | + cmd.Connection = connection; |
|
| 115 | + IDbDataAdapter dataAdapter = new SqlDataAdapter(cmd); |
|
| 116 | + dataAdapter.Fill(ds); |
|
| 117 | + } |
|
| 118 | + return ds.Tables[0].Rows.Count == 0 ? string.Empty : ds.Tables[0].Rows[0][0].ToString(); |
|
| 119 | +} |
|
| 120 | +``` |
|
| 121 | + |
|
| 122 | +In the above example, CurrentUserTenantID will be set to a company ID (such as ALFKI) and the country will be obtained and the language set. |
|
| 123 | + |
|
| 124 | +###Screenshots |
|
| 125 | + |
|
| 126 | +####French |
|
| 127 | + |
|
| 128 | + |
|
| 129 | + |
|
| 130 | +####Arabic |
|
| 131 | + |
|
| 132 | + |
|
| ... | ... | \ No newline at end of file |