Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Removed outdated references to releases

...

Multiexcerpt
MultiExcerptNametestapp

Starting with Appcelerator CLI 5.0.0 or Alloy 1.7.6, you You can generate a new Alloy project using a test application from the Alloy Github repo.  (The source code is copied from the global or local install of the Alloy npm package.)

To create an Alloy application based on a test application, first create a skeleton Titanium project, then run the Alloy new command with the --testapp <path_to_test_app> option.  Pass the option the relative path to the test application after the alloy/test/apps path.

Code Block
languagebash
appc new -t titanium --classic -i com.appc.picker -n AlloyPicker
cd AlloyPicker
appc alloy new --testapp ui/picker

...

To generate the build customization file alloy.jmk, run the following command:

Code Block
langbash
appc lloyalloy generate jmk [-o path_to_project/app]

...

  • language – Optional. The two-letter language code (en or es, for example) of the target language. If not specified, the default is en (English).
  • --apply – Optional. If present, the command writes new localization entries to the target language 's strings.xml file. Existing i18n entries are left untouched. If the XML file doesn't exist, it is created for you. If this parameter is absent, a preview of the changes are displayed in the terminal window.

...

The command extracts the first parameter (the i18n key) from each localization function and, if it's a string, adds it to the target language 's strings.xml file. For example, suppose a JavaScript file in your application contained the following code:

...

This generates app/i18n/en/strings.xml or (before Alloy 1.8.0) i18n/en/strings.xml in your project directory, if it doesn't exist. The contents of the generated XML file would appear as follows:

Code Block
linenumberstrue
languagehtml/xml
<resources>
  <string name="name">name</string>
  <string name="color">color</string>
  <string name="currency">currency</string>
</resources>

If you later add more localization functions to your code and run the same command again, the new entries would be added to strings.xml. Existing entries are left untouched.

To generate a strings.xml for a specific language, pass the two-letter language code as a parameter. For example, the following command creates a strings.xml file for Spanish language locales (app/i18n/es/strings.xml or - before Alloy 1.8.0 - i18n/es/strings.xml ):

...

The output of this command shows the content of the current en/strings.xml file (before) and its content once you apply the changes (after) with --apply.

Code Block
linenumberstrue
languagehtml/xml
[INFO] ######## BEFORE ########
<resources>
  <string name="name">name</string>
  <string name="color">color</string>
  <string name="currency">currency</string>
</resources>
[INFO] ######## AFTER  ########
<resources>
  <string name="name">name</string>
  <string name="color">color</string>
  <string name="currency">currency</string>
  <string name="test">test</string>
</resources>

Compiling a specific view-controller

Starting with Appcelerator CLI 5.0.0 or Alloy 1.7.6, you You can select which Alloy view-controller to compile to Titanium code.  Use the command to update the Titanium base code for incremental changes to the Alloy project.  Pass the file=<filename> to the --config option when running the Alloy compile command.

...