@@ -105,19 +63,100 @@ When translating strings in an extension, ts scope needs to be declared. The `CR
</div>
```
* When possible, avoid HTML formatting and newlines inside `{ts}...{/ts}` tags.
## Best practices
* Good
### Avoid tags inside strings
```smarty
<p>{ts}Hello, world!{/ts}</p>
```
!!! failure "Bad"
* Bad
```smarty
{ts}<p>Hello, world!</p>{/ts}
```
!!! success "Good"
```smarty
<p>{ts}Hello, world!{/ts}</p>
```
### Avoid multi-line strings
Even if your code editor may not like it, long strings should be on a single line since a change in indentation might change where the line breaks are, which would then require re-translating the string.
!!! failure "Bad"
```
{ts}<p>Hello, world!</p>{/ts}
```
```php
$string=ts("Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Proin elementum, ex in pretium tincidunt, felis lorem facilisis
lacus, vel iaculis ex orci vitae risus. Maecenas in sapien ut velit
scelerisque interdum.");
```
!!! success "Good"
```php
$string = ts("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin elementum, ex in pretium tincidunt, felis lorem facilisis lacus, vel iaculis ex orci vitae risus. Maecenas in sapien ut velit scelerisque interdum.");
```
### Avoid escaped quotes
!!! failure "Bad"
```php
$string=ts('A new \'%1\' has been created.',array(1=>$contactType));
```
!!! success "Good"
```php
$string = ts("A new '%1' has been created.", array(1 => $contactType));