Integration/Tutorials/Localization.md
... ...
@@ -73,16 +73,90 @@ Let’s suppose you need Izenda Reports in French. Here is a step-by-step list o
73 73
74 74
###How To Set The Language I Want To Use?
75 75
76
-You should specify the AdHocSettings.Language setting in the code. Normally it’s done in the PostLogin() method (or ConfigureSettings() method if you’d like to all users use the same language) of CustomAdHocConfig in the Global.asax file:
76
+You should specify the AdHocSettings.Language setting in the code. This should be done in the [[InitializeReporting() method in the CustomAdHocConfig class in the Global.asax file. You can set this globally for all users or use logic to change the language per user or per tenant as you like.
77 77
78
-``` c#
79
-public override void PostLogin()
78
+####Global
79
+
80
+``` csharp
81
+public static void InitializeReporting()
80 82
{
81 83
AdHocSettings.Language = AdHocLanguage.French;
82 84
}
83 85
84 86
```
85 87
88
+####Per Country By Tenant(Customer) ID
89
+
90
+```csharp
91
+public static void InitializeReporting()
92
+{
93
+ switch ( GetUserCountry()){
94
+ case "USA":
95
+ case "UK":
96
+ case "Ireland":
97
+ AdHocSettings.Language = AdHocLanguage.English;
98
+ break;
99
+ case "France":
100
+ AdHocSettings.Language = AdHocLanguage.French;
101
+ break;
102
+ case "Spain":
103
+ case "Mexico":
104
+ case "Venezuela":
105
+ case "Argentina":
106
+ case "Brazil":
107
+ AdHocSettings.Language = AdHocLanguage.Spanish;
108
+ break;
109
+ case "Germany":
110
+ case "Austria":
111
+ case "Poland":
112
+ case "Switzerland":
113
+ AdHocSettings.Language = AdHocLanguage.German;
114
+ break;
115
+ case "Russia":
116
+ AdHocSettings.Language = AdHocLanguage.Russian;
117
+ break;
118
+ case "Japan":
119
+ AdHocSettings.Language = AdHocLanguage.Japanese;
120
+ break;
121
+ case "China":
122
+ AdHocSettings.Language = AdHocLanguage.ChinesePeoplesRepublicofChina;
123
+ break;
124
+ case "Taiwan":
125
+ AdHocSettings.Language = AdHocLanguage.ChineseTaiwan;
126
+ break;
127
+ case "Italy":
128
+ AdHocSettings.Language = AdHocLanguage.Italian;
129
+ break;
130
+ case "South Korea":
131
+ case "North Korea":
132
+ case "Korea":
133
+ AdHocSettings.Language = AdHocLanguage.Korean;
134
+ break;
135
+ case "Belgium":
136
+ AdHocSettings.Language = AdHocLanguage.Dutch;
137
+ break;
138
+ default:
139
+ AdHocSettings.Language = AdHocLanguage.English;
140
+ break;
141
+ }
142
+}
143
+
144
+public static string GetUserCountry() {
145
+ String sql = string.Format(@"SELECT [dbo].[Customers].[Country] FROM [dbo].[Customers] WHERE [dbo].[Customers].[CustomerID] = '{0}'", AdHocSettings.CurrentUserTenantId);
146
+ SqlCommand cmd = new SqlCommand(sql);
147
+ DataSet ds = new DataSet();
148
+ using (SqlConnection connection = new SqlConnection(AdHocSettings.SqlServerConnectionString)) {
149
+ connection.Open();
150
+ cmd.Connection = connection;
151
+ IDbDataAdapter dataAdapter = new SqlDataAdapter(cmd);
152
+ dataAdapter.Fill(ds);
153
+ }
154
+ return ds.Tables[0].Rows.Count == 0 ? string.Empty : ds.Tables[0].Rows[0][0].ToString();
155
+}
156
+```
157
+
158
+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.
159
+
86 160
###Can I Change Some Or All Of The Resources?
87 161
88 162
Yes, you can change the localization by yourself.