PHPackages                             nobox/lazy-strings - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. nobox/lazy-strings

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

nobox/lazy-strings
==================

Create localized strings from a Google Docs Spreadsheet.

v5.0.1(10y ago)57372MITPHPPHP &gt;=5.4.0

Since Aug 23Pushed 10y ago6 watchersCompare

[ Source](https://github.com/Nobox/Lazy-Strings)[ Packagist](https://packagist.org/packages/nobox/lazy-strings)[ Docs](https://github.com/Nobox/Lazy-Strings)[ RSS](/packages/nobox-lazy-strings/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (1)Versions (20)Used By (2)

Lazy Strings
============

[](#lazy-strings)

Create localized strings from a Google Docs Spreadsheet.

[![Build Status](https://camo.githubusercontent.com/8bb18afcf3a99ec807c82d469448e0360a3c2a5cad2f18b52755fcd11a30456e/68747470733a2f2f7472617669732d63692e6f72672f4e6f626f782f4c617a792d537472696e67732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Nobox/Lazy-Strings)

Installation
------------

[](#installation)

Add Lazy Strings to your composer.json file.

```
composer require nobox/lazy-strings
```

Usage
-----

[](#usage)

Create an instance of LazyStrings with the following settings.

```
$lazyStrings = new LazyStrings([
    'url' => 'http://docs.google.com/spreadsheets/d/1V_cHt5Fe4x9XwVepvlXB39sqKXD3xs_QbM-NppkrE4A/export?format=csv',
    'sheets' => [
        'en' => 0,
    ],
    'target' => 'path/to/strings/folder',
    'backup' => 'path/to/strings/folder',
    'nested' => true
]);
```

And generate your strings with the `generate();` method.

```
$lazyStrings->generate();
```

Settings
--------

[](#settings)

Each setting key item is described below.

### `url`

[](#url)

Add the Google spreadsheet published url. This should be done with `File -> Publish to the web...`, replace `pubhtml` with `export?format=csv` at the end and use `http` on the url. Remember that this document must be available to anyone. Use `Public on the web` on your `Sharing settings`. If not, Lazy Strings won't be able to parse it.

```
'url' => 'http://docs.google.com/spreadsheets/d/1V_cHt5Fe4x9XwVepvlXB39sqKXD3xs_QbM-NppkrE4A/export?format=csv'
```

### `sheets`

[](#sheets)

Here you'll specify all the sheets in your Google doc (if it's more than one) with their id, each separated by locale. Use an array if using more than one sheet for a locale. Example:

```
'sheets' => [
    'en' => [0, 1626663029],
    'es' => 1329731586,
    'pt' => 1443604037
]
```

You can take the id from the spreadsheet using the `gid` variable from your Google doc url. For example, in this spreadsheet: [https://docs.google.com/a/nobox.com/spreadsheets/d/1V\_cHt5Fe4x9XwVepvlXB39sqKXD3xs\_QbM-NppkrE4A/edit#gid=1626663029](https://docs.google.com/a/nobox.com/spreadsheets/d/1V_cHt5Fe4x9XwVepvlXB39sqKXD3xs_QbM-NppkrE4A/edit#gid=1626663029) the id is `1626663029`.

### `target`

[](#target)

Here you must specify a path where to store your translations.

```
'target' => 'path/to/strings/folder'
```

Using these settings it will generate the following translation files in `path/to/strings/folder`.

```
├── folder/
│   ├── en/
│   │   ├── lazy.php
│   ├── es/
│   │   ├── lazy.php
│   ├── pt/
│   │   ├── lazy.php

```

### `backup`

[](#backup)

Here you must specify a path where to store your translations in JSON format. More like a "backup" of your strings.

```
'backup' => 'path/to/strings/folder'
```

Using these settings it will generate the following translation files in `path/to/strings/folder`.

```
├── folder/
│   ├── es.json
│   ├── en.json
│   ├── pt.json

```

### `nested`

[](#nested)

Specify whether or not you want your translations array to be nested.

```
'nested' => true
```

If you use the nested setting as `true` your translations will look like something like this:

```
