Coder Social home page Coder Social logo

cobeisfresh / localizable-sheet-script Goto Github PK

View Code? Open in Web Editor NEW
225.0 7.0 78.0 11 KB

A Google Sheets script that will take a sheet in a specific format and return iOS and Android localization files.

JavaScript 100.00%
google-sheets google-sheets-api ios android google-apps-script

localizable-sheet-script's Introduction

localizable-sheet-script

A Google Sheets script that will take a sheet in a specific format and return iOS and Android localization files.

What it does

For Android it creates an XML resources file with all of the strings. For iOS it creates a Localizable enum with String constants, and a .strings file.

Installing

  1. Open your sheet.
  2. Go to Tools -> Script Editor
  3. Copy Code.js, make your edits if needed, and Save.

Usage

  1. Open your sheet.
  2. Go to Custom Export and select your iOS or Android.

Sheet format

The script expects the sheet to be formatted in a specific way.

... arbitrary number of columns before iOS keys Identifier iOS Identifier Android English text German text ...
place whatever you want in here login_button_title login_button_title Login Einloggen
... ... ... ...

The texts in bold cannot be changed! The script depends on them to know which identifier is which. The other texts don't matter.

The first row must always contain headers, and not the actual strings.

The number of languages depends on the NUMBER_OF_LANGUAGES variable in the script, and new languages can be added by adding a new column on the right and incrementing that number in the script.

The position of the first (iOS) column that is relevant to the script is changed with the FIRST_COLUMN_POSITION variable in the script. By default it's 1 (the first column).

Configuring

  • NUMBER_OF_LANGUAGES: The number of language columns to use.
  • FIRST_COLUMN_POSITION: The position of the iOS identifiers (the first column relevant to the script). Starting from 1.
  • IOS_INCLUDES_LOCALIZABLE_ENUM: Whether or not to create an Localizable enum containing all of the keys as static let constants.

Exported files

The exported files are the standard format (strings.xml or Localizable.strings) for the specific platforms. iOS also includes a Localizable enum which contains all of the keys as static let properties for code-completion and less typos. 

License: MIT

Created by COBE http://cobeisfresh.com/ Copyright 2017 COBE

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

localizable-sheet-script's People

Contributors

jamieadkins95 avatar marinbenc avatar matijagorsek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

localizable-sheet-script's Issues

Tiny bug for HEADER_ROW_POSITION

I found a problem when I changed HEADER_ROW_POSITION

The reason may be at line 278
var headersRange = sheet.getRange(1, FIRST_COLUMN_POSITION, HEADER_ROW_POSITION, sheet.getMaxColumns());
It should be
var headersRange = sheet.getRange(HEADER_ROW_POSITION, FIRST_COLUMN_POSITION,1, sheet.getMaxColumns());
Please confirm then fix it if I correct

`TypeError: Cannot call method "indexOf" of undefined.` when exporting Android strings

Can you please show me a sample google sheets that's working?
Right now, I am getting an error that reads like this: TypeError: Cannot call method "indexOf" of undefined.

That's when I export for android. The iOS export works fine on the other hand...

This is what the sheet looks like, I used the new code and froze row 1:

iOS t Android t Text english Text Hebrew
login_button_title login_button_title Login התחברות

UiApp has been deprecated

The script does not work anymore due to UiApp deprecation:

UiApp has been deprecated. Please use HtmlService instead

Are you going to update the source code?

Not working

I followed the instructions and set this as my example, but it produce an error saying i didn't have the right amount of rows/columns: The coordinates or dimensions of the range are invalid.

And this is what the sheets doc looks like:
Identifier iOS Identifier Android English text
login_button_title login_button_title Login

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.