Skip to content

Latest commit

ย 

History

History
154 lines (94 loc) ยท 5.4 KB

Localizing-with-Xcode9.md

File metadata and controls

154 lines (94 loc) ยท 5.4 KB

Localizing with Xcode 9

๐Ÿ“… 2019.11.11 (์›”)

WWDC 2017 | Session : 401 | Category : Xcode

๐Ÿ”— Localizing with Xcode 9 - WWDC 2017 - Videos - Apple Developer

๊ท€์šฅ๋”ฐ

Internationallization

์–ธ์–ด๊ฐ€ ๊ธธ๋˜ ์งง๋˜, ์˜ค๋ฅธ์ชฝ์—์„œ ์™ผ์ชฝ์œผ๋กœ ์“ฐ๋˜, ๋™์ ์œผ๋กœ ์ด ๋ชจ๋“  ์‹œ๋‚˜๋ฆฌ์˜ค์— ์ ์šฉํ•ด์•ผ ํ•œ๋‹ค.

String Management

๋Ÿฐํƒ€์ž„ ์‹œ NSLocalizedString ์„ ์‚ฌ์šฉํ•˜๋ฉด ์•Œ๋งž๋Š” ๋ฒˆ์—ญ ๋œ ์–ธ์–ด๋ฅผ display ํ•˜๋Š” ๊ฒƒ์„ ์‰ฝ๊ฒŒ ๋งŒ๋“ค์–ด ์ค€๋‹ค.

Storyboard ๋‚˜ zip ํŒŒ์ผ์— ์žˆ๋Š” String์€ default๋กœ ํ˜„์ง€ํ™” ํ•  ์ˆ˜ ์žˆ๋‹ค.

ํ•˜์ง€๋งŒ ์—๋Ÿฌ ๋ฉ”์„ธ์ง€๋‚˜ notification ๊ฐ™์€ ์†Œ์Šค ์ฝ”๋“œ์— ์ •์˜ ๋˜์–ด ์žˆ๋Š” String๋„ ์žˆ์„ ์ˆ˜ ์žˆ๋‹ค. ์ด String๋“ค์„ NSLocalizedStringForm ์œผ๋กœ ๊ฐ์‹ธ๋ฉด ๋œ๋‹ค.

NSLocalizedWithFormat ์œผ๋กœ formatted string์„ ์‚ฌ์šฉ ํ•  ์ˆ˜ ์žˆ๋‹ค.

    // Set a label's text
    label.text = "Population"
    
    // Set a label's text to a localized string
    label.text = NSLocalizedString("Population", comment: "Label preceding the population value") 
    
    // Load localized string from a specific table 
    label.text = NSLocalizedString("Poluation", tableName: "Localizable", bundle: .main, value: nil, comment: "Label preceding the population value") 
    
    
    // Create a formatted string
    let format = NSLocalizedString("%d popular languages, comment: "Number of popular languages")
    label.text = String.localizedStrinWithFormat(format, popularLanguages.count)

comment โ†’ ๋ฒˆ์—ญ ๋  string์— ๋Œ€ํ•œ ๋งฅ๋ฝ ์ œ๊ณต

tableName โ†’ framework๋‚˜ shared component๋ฅผ ์‚ฌ์šฉ ์‹œ ์ถœ์ฒ˜๋ฅผ ์œ„ํ•ด tableName ์‚ฌ์šฉ

localizedStringWithFormat format ๋˜๋Š” String ์ธ์ง€ ํ•˜๊ธฐ ์œ„ํ•ด ๋ฌธ๋งฅ ํŒŒ์•… ํ•ด์•ผ ํ•จ

fb.Iproj/Localizeable.string

    /* Title label's text */
    "International Facts" = "Faits Internationaux";
    
    /* Label prompting a user to choose a territory */ 
    "Territory" = "Territoire";

๋Ÿฐํƒ€์ž„ ์‹œ, NSLocalizedString ์€ ์œ ์ €์˜ ์„ ํ˜ธ language๋ฅผ ๊ฒฐ์ • ํ•˜๊ณ , localized string file์„ ์ฐพ์„ ๊ฒƒ์ด๋‹ค.

Formatting

๋‚ ์งœ, ์‹œ๊ฐ„, ์ˆซ์ž ๋“ฑ์— ๋Œ€ํ•œ ๋‹ค๋ฅธ ์‹œ๊ฐ์ ์ธ ํ‘œํ˜„์— ๋Œ€ํ•œ ์ง€์—ญํ™”

Date and time

User Interface

๋ชจ๋“  ์–ธ์–ด์—์„œ UI๊ฐ€ flexibleํ•ด์•ผ ํ•˜๊ณ  niceํ•ด ๋ณด์—ฌ์•ผ ํ•œ๋‹ค.

  1. Xcode๊ฐ€ Destructor์„ ์œ„ํ•ด ํ”„๋กœ์ ํŠธ๋ฅผ ์ˆ˜์ • ํ•  ๊ฒƒ์ด๋‹ค.
  2. ๊ทธ๋ฆฌ๊ณ  UI๋ฅผ String์œผ๋กœ ๋ถ€ํ„ฐ ๋ถ„๋ฆฌ ํ•  ๊ฒƒ์ด๋‹ค. โ†’ User Interface์™€ ๊ด€๋ จ ๋œ ํŒŒ์ผ์€(zip ํŒŒ์ผ์ด๋‚˜ storyboardํŒŒ์ผ ๊ฐ™์€) Base.lproj ์— ์ €์žฅ ๋  ๊ฒƒ์ด๋‹ค
  3. ์Šคํ† ๋ฆฌ๋ณด๋“œ ํŒŒ์ผ์ด๋‚˜ NSLocalizedString์„ ํ†ตํ•ด์„œ unwrap ๋œ String์€ ํŠน์ • ์–ธ์–ด ํด๋”์— ์ €์žฅ ๋  ๊ฒƒ์ด๋‹ค. โ†’ ์•ฑ์˜ ์ƒˆ๋กœ์šด ์–ธ์–ด๋ฅผ ๋งŒ๋“ค ๋•Œ ๋งˆ๋‹ค, ๋ณต์‚ฌํ•˜๋Š” ๋Œ€์‹ ์— User Interface์— ํ•˜๋‚˜์˜ ํŠน์ • ์–ธ์–ด ํด๋”๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋„๋ก
  4. base internationalization์€ Xcode 5๋ถ€ํ„ฐ default๋กœ ๊ฐ€๋Šฅ ํ•˜๋‹ค.

๐Ÿ†• Localization warnings โ†’ localization์„ ๊ณ ๋ ค ํ•˜์ง€ ์•Š์€ constraint์— warning

๐Ÿ†• Pseudolocalization ์–ธ์–ด ๋งˆ๋‹ค ํŠน์ง•์„ ์ ์šฉํ•ด์„œ ๋ฏธ๋ฆฌ ๋ณผ ์ˆ˜ ์žˆ์Œ

Summary

  • Use standard APIs to handle the complexity of data formatting
  • User base internationalization and Auto Layout
  • Validate your strings and UI

Localization Workflow

Localization Process

  1. Xcode๋Š” ํ”„๋กœ์ ํŠธ์— ๋ชจ๋“  localizable resource๋ฅผ ์ฐพ์•„์„œ,
  2. ํ”„๋กœ์ ํŠธ๊ฐ€ localization ์„ ์œ„ํ•ด export ๋  ๋•Œ, Xcode๋Š” localizable resource๋“ค๋กœ ๋ถ€ํ„ฐ string์„ ์ถ”์ถœํ•ด์„œ ๋‹น์‹ ์ด ์ถ”๊ฐ€ํ•œ ๋ชจ๋“  ์–ธ์–ด์— ๋Œ€ํ•œ XLIFF ํŒŒ์ผ์„ ์ƒ์„ฑ ํ•  ๊ฒƒ์ด๋‹ค
  3. XLIFF ํŒŒ์ผ์€ localization ์‚ฐ์—…์—์„œ ํ‘œ์ค€ standard XML localization file์ด๋‹ค.
  4. localizer ์ค‘ ํ•˜๋‚˜์—๊ฒŒ XLIFF ํŒŒ์ผ์„ ๋ณด๋‚ด๋ฉด, ์ด๋ฏธ ํฌ๋งท๊ณผ ์‚ฌ์šฉ๋ฒ•์— ๋Œ€ํ•ด ์นœ์ˆ™ ํ•  ๊ฒƒ์ด๋‹ค.
  5. ์ผ๋‹จ XLIFF ํŒŒ์ผ์ด ๋ฒˆ์—ญ ๋˜๋ฉด Xcode์— import ํ•  ์ˆ˜ ์žˆ๊ณ  ์ž๋™์œผ๋กœ localized text์— ํ†ตํ•ฉ ๋  ๊ฒƒ์ด๋‹ค

โ†’ ์ด๊ฒƒ์ด Xcode ์˜ localization ํ•˜๋Š” ๊ณผ์ •์ด๋‹ค. ๋งค์šฐ ๊ฐ„๋‹จํ•˜๊ณ  ์ง๊ด€์ ์ด๋‹ค.

๐Ÿ†• Stringdict

Xcode9์—์„œ String dic format์˜ String์„ export, import์— ๋Œ€ํ•œ ์ง€์›์„ ์ถ”๊ฐ€ ํ–ˆ๋‹ค.

๐Ÿ†• Adaptive Strings

Summary

  • Use strings dict for plurals and width variants
  • Export XLIFF for localization
  • Import localized XLIFF
  • Localize non-string resources in Xcode

Testing

XCTest

UITest

์œ„ ์ฝ”๋“œ๋Š” localization์ด ์•ˆ๋˜๊ณ , ํ…Œ์ŠคํŠธ๋ฅผ ์‹คํ–‰ํ•˜๋Š” ๊ฐ๊ฐ์˜ ์–ธ์–ด๋กœ ๋ฒˆ์—ญ ๋  ๊ฒƒ์ด๋‹ค

accessibilityIdentifier ์„ ์‚ฌ์šฉํ•˜๋ฉด ํ™”๋ฉด์˜ ๋ชจ๋“  element์— ๊ณ ์œ ํ•˜๊ณ , ํ•ด๋‹น element์— ์–ด๋–ค string์ด load ๋˜๋Š”์ง€ ๋ชจ๋ฅธ์ฑ„ ์‚ฌ์šฉ ํ•  ์ˆ˜ ์žˆ๋‹ค.

Set accessibilityIdentifier

    button.accessibilityIdentifier = "startButton"

  • Use accessibility identifiers
  • Use XCTAttachment to collect screenshots
  • Get full coverage of UI for all localizations

Summary

  • Prepare your app for localization
  • Validate your app's readiness
  • Export localizable content to be translated
  • Import localized content
  • User XCTest to test your localized app