|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE task |
|
11 PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd"> |
|
12 <task id="GUID-DDA0ECF7-BC92-4AFB-998F-5FDD300655FB" xml:lang="en"><title>Getting |
|
13 a Nearest Equivalent Language</title><abstract><p>In this example, the system language is <codeph>ELangCanadianEnglish</codeph> and |
|
14 there is no exact match of the resource file on the system. The application |
|
15 calls <xref href="GUID-5F9CAA3E-D8BF-3488-9797-3B9FB4452930.dita#GUID-5F9CAA3E-D8BF-3488-9797-3B9FB4452930/GUID-EA0690FF-419D-353C-BBED-95000E21F843"><apiname>BaflUtils::NearestLanguageFileV2()</apiname></xref> to get the closest |
|
16 match. There are three available resource files: </p> <ul> |
|
17 <li id="GUID-3CBF0BF9-04E1-5211-B2CF-53B40FEF7FF4"><p> <filepath>c:\FileMenu.rsc</filepath> is |
|
18 the language-neutral resource file. </p> </li> |
|
19 <li id="GUID-406A6D60-19B9-5233-BE6F-28EF10E70C1F"><p> <filepath>c:\FileMenu.r01</filepath> is |
|
20 for <codeph>ELangEnglish</codeph>. </p> </li> |
|
21 <li id="GUID-22C5F02D-2D36-5C51-BDFC-498BDB717059"><p> <filepath>c:\FileMenu.r10</filepath> is |
|
22 for <codeph>ELangAmerican</codeph>. </p> </li> |
|
23 </ul> </abstract><prolog><metadata><keywords/></metadata></prolog><taskbody> |
|
24 <steps id="GUID-4DD07DEC-6017-4237-BE46-1D69E5FBD744-GENID-1-7-1-11-1-1-8-1-5-1-5-1-5-1-8-1-5-1-3-1"> |
|
25 <step id="GUID-9A69E5AD-E938-4092-A8C2-CB65C37C8962-GENID-1-7-1-11-1-1-8-1-5-1-5-1-5-1-8-1-5-1-3-1-1"><cmd/> |
|
26 <info><p>In the application, define a string with the neutral-language resource |
|
27 file name. </p> <codeblock id="GUID-438C8582-247E-5109-9E3B-ABC38818E6E2" xml:space="preserve">_LIT(KRscFilename, "C:\\FileMenu.rsc"); </codeblock></info> |
|
28 </step> |
|
29 <step id="GUID-9E49C0AD-8007-461A-A019-AC792ACA9997"><cmd/> |
|
30 <info><p>Create a session with the File Server to search the file system for |
|
31 available resource files. <codeblock id="GUID-D1DD087E-ECE9-5BD6-984F-B427AA96E838" xml:space="preserve">RFs fileServerSession; |
|
32 CleanupClosePushL(fileServerSession); |
|
33 User::LeaveIfError(fileServerSession.Connect());</codeblock></p></info> |
|
34 </step> |
|
35 <step id="GUID-3D9B43BD-E641-441E-8795-0CEF53BD231C"><cmd/> |
|
36 <info><p>Construct a buffer to save a resource file name. The buffer takes |
|
37 the neutral-language resource file name as a input parameter to <xref href="GUID-5F9CAA3E-D8BF-3488-9797-3B9FB4452930.dita#GUID-5F9CAA3E-D8BF-3488-9797-3B9FB4452930/GUID-EA0690FF-419D-353C-BBED-95000E21F843"><apiname>BaflUtils::NearestLanguageFileV2()</apiname></xref>. |
|
38 It will be updated with a new value after the call. <codeblock id="GUID-4CB6F88B-E26B-54C6-919A-BB812913947D" xml:space="preserve">TBuf<256> filename; |
|
39 filename.Copy(KRscFilename);</codeblock></p></info> |
|
40 </step> |
|
41 <step id="GUID-C785E5AD-EB3A-4A76-9D27-E564F5CB970D"><cmd/> |
|
42 <info><p>Define a <xref href="GUID-698538DF-DCDC-347B-BD32-DD9EB896BAFB.dita"><apiname>TLanguage</apiname></xref> as a return parameter for the |
|
43 nearest equivalent language. <codeblock id="GUID-5D7ABE60-B9D7-5A33-A219-A6144C539817" xml:space="preserve">TLanguage lang=ELangNone;</codeblock></p></info> |
|
44 </step> |
|
45 <step id="GUID-C3A49C71-5071-40DA-91D8-012CD47D3BD8"><cmd/> |
|
46 <info><p>Get the nearest language. <codeblock id="GUID-B9F41C54-782A-5650-AAD9-EB3291B6E6BA" xml:space="preserve">BaflUtils::NearestLanguageFileV2(fileServerSession, filename, lang); |
|
47 ...</codeblock></p></info> |
|
48 </step> |
|
49 <step id="GUID-C8A8A118-B7F8-4F6D-AD9A-33FBD61D9C33"><cmd/> |
|
50 <info><p>Close the session with the File Server. <codeblock id="GUID-DA7D701D-2BA6-536C-B4A2-3FDCA5DD23C3" xml:space="preserve">CleanupStack::PopAndDestroy (&fileServerSession);</codeblock></p></info> |
|
51 </step> |
|
52 </steps> |
|
53 <result> <p> The <codeph>filename</codeph> parameter is updated as <filepath>"c:\\FileMenu.r10"</filepath> which |
|
54 is the closest resource file for <codeph>ELangCanadianEnglish</codeph>. The <codeph>lang</codeph> parameter |
|
55 is returned as <codeph>ELangAmerican</codeph> (value 10) which is the nearest |
|
56 equivalent language. </p> </result> |
|
57 </taskbody></task> |