Programing

현지화 된 스토리 보드 문자열을 업데이트 할 수 있습니까?

lottogame 2020. 4. 30. 07:23
반응형

현지화 된 스토리 보드 문자열을 업데이트 할 수 있습니까?


나는 base.lproj 스토리 보드와 3 개의 문자열 파일을 생성하여 응용 프로그램의 일부를 현지화했습니다. 한 달 전과 후에 앱에 새보기 컨트롤러를 추가했지만이 컨트롤러의 버튼과 레이블이 문자열 파일에 나타나지 않습니다.

이 3 개의 스토리 보드 첨부 문자열 파일을 업데이트 할 수 있습니까? 아니면 NSLocalizableString 및 Localizable.strings를 사용하여 프로그래밍 방식으로 새 문자열 번역을 추가해야합니까?


두 가지 옵션이 있습니다.

옵션 1

Xcode는 파일을 [Interface Builder Cocoa Touch Storyboard] 파일 형식 또는 [Localizable Strings] 파일 형식 으로 변환하여 파일을 "재로드"할 수 있습니다 .

  1. 프로젝트 네비게이터에서 기본 스토리 보드 파일을 선택하십시오.
  2. 파일 관리자에서 현지화 섹션을 찾습니다
  3. 파일이 현재 [Localizable Strings] 인 경우 [Interface Builder Cocoa Touch Storyboard]로 변경하거나 그 반대로 변경하십시오.
  4. Xcode는 스토리 보드를 현재 버전으로 변환하면서 이전 현지화 노력을 유지해야합니다. 원하는 경우 파일을 원래 파일 형식으로 다시 변경할 수 있습니다.

옵션 2

스토리 보드에서 문자열을 추출하려면 ibtool을 사용하십시오.

  1. 터미널 응용 프로그램을 엽니 다
  2. Base.lproj 디렉토리를 찾으십시오
  3. 이 줄을 사용하여 문자열을 추출하십시오.

    ibtool MainStoryboard.storyboard --generate-strings-file file_name.strings

  4. ibtool이 문자열을 file_name.strings로 추출한 후이를 복사하여 원래 .strings 파일에 붙여 넣을 수 있습니다

자세한 정보를 보려면 다음 사이트를 방문하십시오 : https://conyac.cc/business/columns/localization_guide_ios


BartyCrouch를 확인하면 문제가 완벽하게 해결됩니다. 또한 오픈 소스 이며 적극적으로 유지 관리 되며 프로젝트 내에 쉽게 설치 및 통합 할 수 있습니다 .


Homebrew 를 통해 BartyCrouch를 설치 하십시오 .

brew install bartycrouch

또는 Mint 를 통해 설치하십시오 .

mint install Flinesoft/BartyCrouch

Storyboards / XIBs Strings 파일을 점차적으로 업데이트 하십시오.

$ bartycrouch update

이것은 당신이 찾고 있던 것을 정확하게 할 것입니다.


하기 위해 계속 하여 스토리 보드를 / XIBs 문자열은 파일 시간이 지남에 따라 업데이트 내가보기 엔 빌드 스크립트를 (빌드 스크립트를 추가하는 방법에 대한 지침을 추가하는 것이 좋습니다 여기를 )

if which bartycrouch > /dev/null; then
    bartycrouch update -x
    bartycrouch lint -x
else
    echo "warning: BartyCrouch not installed, download it from https://github.com/Flinesoft/BartyCrouch"
fi

점차적으로 당신의 스토리 보드를 업데이트 외에도 / XIBs 문자열이는 것 파일을 확인하십시오 할 Localizable.strings파일이 업데이트 유지 새로 추가하여 코드에서 키 NSLocalizedString중복 키 또는 빈 값 및 경고보기.

자세한 내용GitHub 또는 이 자세한 기사 에서 BartyCrouch를 확인하십시오 .


현지화 파일에 키를 수동으로 추가 할 수 있습니다. 스토리 보드 편집기에서 키 오브젝트를 선택하여 찾을 수 있습니다. Object-ID아이덴티티 인스펙터를 봅시다 . 마치"nwc-b2-19c"

현지화 업데이트 또는 번역 추가 예를 들면 다음과 같습니다.

"nwc-b2-19c.title" = "Translated title";

This one is not for everybody, but it requires no additional tools in the terminal and it's easy for small manual changes. (Do not consider this when you want to automate your process.)

Step 0: Storyboard language setup

  • Base (with english texts)
  • English (localizable strings file does not exist because the base file is english)
  • other languages (localizable strings files)

base configuration

This step is done only once.

Now when I add something to the storyboard I do the following

Step 1: add the English localizable strings file

Add English

just mark the English line item.

This creates a completely new english localizable strings file with all the lines

Step 2: copy the new line items into the other language files

and translate them

Step 3: unmark English, remove the corresponding localizable strings file

the file was only needed to get the new line items

This is an easy and fast process, everything is done in the storyboard editor

Edit:

This process works very well with small storyboards. For example, I have a tabs based project and I have a storyboard for each tab.

Search for "storyboard reference" to find tutorials.

Good example: Storyboard reference in Xcode, where should we use it?

So each small storyboard only has a few strings to localize.


Finally, my solution was (rudimentary but effective) copy the previous translations and paste them in the a new file created by unchecking and checking the Localization language box.

This would be useful in some cases like mine when you have to change only one or two texts.


I think the best way is by using built-in export/import Localizations:

  1. In Project Navigator choose you project folder
  2. Choose Editor > Export For Localization,
  3. All translations left on their places and XCode add missed strings automatically. Additionally, before import, you can edit .xliff in XLIFF Editor (for example, online - http://xliff.brightec.co.uk) and then you don't need to do this in XCode.
  4. then Editor > Import Localizations and choose saved .xliff file.

P.S. If you don't want to edit in XLIFF Editor and have skipped step 3, XCode can didn't save new strings. In this case open .xliff in XLIFF Editor, re-save without changes and import new file.


When you click in your storyboard, Main.storyboard for example... On right side you can see the localization menu (see atached image). If you uncheck and check again a lenguage, the file will be generated again. So I usually copy the content, I generate the file again and then I paste the content that I copied and already been translated.

This is the way that I use to update the dictionary.

enter image description here


There is an app a command line tool from Apple named AppleGlot that supports incremental localisation. I haven't tried it yet, but it looks exactly like the tool you searched for (some time ago).


Here is a script to extract strings from storyboards and xibs, and merge them with existing translations.

To run the script automatically when you build a project, put the script into your project root directory, and add a Run Script phase with the following line to a target build phases in your project settings.

./mergegenstrings.py PathToSourceDir

Or you can run the script on Terminal manually when you want to.

The script runs ibtool as Tha Leang answered. It also runs genstrings to extract and merge strings marked with NSLocalizedString in your source code. The script is based on a script in this post, which merges strings after running genstrings.


I got a huge storyboard with a lot of strings there. Two languages base english and another arabic. The task was to add some fields and labels to storyboard and add localization for them without any scripts and NSLocalizableStrings.

For me helped next:

First: Ensure, you have git to prevent unexpectable changes.

  1. Go to target screen in xcode and press Editor -> Export For Localization.... Save the ar.xliff file somewhere.
  2. Download XLIFF Edtior.
  3. Open ar.xliff file and make changes.
  4. Import this file in xcode. Done! You have updated storyboard strings file.

The easiest and very less risky approach is, just copy the Object ID from the storyboard and add a new key for the key in the localized file as below example:

1: Copy object id as below from storyboard for the component:

enter image description here

2: Add new key in localised file like below:

"DjF-dn-0ay.text" = "Borrar datos y restablecer";

Note: This is very less risky approach if you want to update only few component otherwise you can recreate localised file for the storyboard.


This is my easy way to update new text from storyboard or xib to localization string

1- use this script http://tredje.se/dev/trouble/?x=entry:entry150917-204052

2- select your localization string that you want to update and switch your language string from "Localization string" to "interface builder storyboard"

3- switch it back :)

Done.

enter image description here

참고URL : https://stackoverflow.com/questions/15094259/is-it-possible-to-update-a-localized-storyboards-strings

반응형