1# Globalization Subsystem Changelog 2 3## cl.resourceManager.1 Addition of getStringSync and getStringByNameSync APIs 4 5Added the **getStringSync** and **getStringByNameSync** APIs and error codes to obtain and format strings. 6 7| Bundle Name | API | 8| --------------- | ---------------------------------------------------- | 9| ohos.resourceManager.d.ts | getStringSync(resId: number, ...args: Array<string \| number>): string; | 10| ohos.resourceManager.d.ts | getStringSync(resource: Resource, ...args: Array<string \| number>): string; | 11| ohos.resourceManager.d.ts | getStringByNameSync(resName: string, ...args: Array<string \| number>): string; | 12 13**Change Impact** 14 15In versions earlier than 4.0.6.2, only the values of string resources can be directly obtained. In 4.0.6.2 or later, the values of string resources can be formatted based on the input arguments for enhanced query. 16 17The following error codes are added: 18 199001007 If the resource obtained by resId formatting error. 20 219001008 If the resource obtained by resName formatting error. 22 23**Sample Code** 24 25The following uses **getStringSync** as an example. Before the change, only example 1 is supported. After the change, both example 1 and example 2 are supported. 26``` 27Example 1: 28try { 29 this.context.resourceManager.getStringSync($r('app.string.test').id); 30} catch (error) { 31 console.error(`getStringSync failed, error code: ${error.code}, message: ${error.message}.`) 32} 33Example 2: 34try { 35 this.context.resourceManager.getStringSync($r('app.string.test').id, "format string", 787, 98.78); 36} catch (error) { 37 console.error(`getStringSync failed, error code: ${error.code}, message: ${error.message}.`) 38} 39``` 40 41**Adaptation Guide** 42For details, see the API reference. 43 44[API Reference](../../../application-dev/reference/apis/js-apis-resource-manager.md) 45 46[Error Codes](../../../application-dev/reference/errorcodes/errorcode-resource-manager.md) 47