aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/markdown/Localisation.md2
-rw-r--r--docs/markdown/Porting-from-autotools.md59
-rw-r--r--docs/markdown/Syntax.md34
3 files changed, 91 insertions, 4 deletions
diff --git a/docs/markdown/Localisation.md b/docs/markdown/Localisation.md
index 27181e5..34cad8d 100644
--- a/docs/markdown/Localisation.md
+++ b/docs/markdown/Localisation.md
@@ -29,7 +29,7 @@ langs = ['fi', 'de']
i18n.gettext('intltest', languages : langs)
```
-The first command imports the `i18n` module that provides gettext features. The second line does the actual invocation. The first argument to the is the gettext package name. This causes two things to happen. The first is that Meson will generate binary mo files and put them to their proper locations when doing an install. The second is that it creates a build rule to regenerate the main pot file. If you are using the Ninja backend, this is how you would invoke the rebuild.
+The first command imports the `i18n` module that provides gettext features. The third line does the actual invocation. The first argument is the gettext package name. This causes two things to happen. The first is that Meson will generate binary mo files and put them to their proper locations when doing an install. The second is that it creates a build rule to regenerate the main pot file. If you are using the Ninja backend, this is how you would invoke the rebuild.
```console
$ ninja intltest-pot
diff --git a/docs/markdown/Porting-from-autotools.md b/docs/markdown/Porting-from-autotools.md
index f9c9ad8..91ed5d2 100644
--- a/docs/markdown/Porting-from-autotools.md
+++ b/docs/markdown/Porting-from-autotools.md
@@ -625,3 +625,62 @@ if not os.environ.get('DESTDIR'):
print('Compiling gsettings schemas...')
subprocess.call(['glib-compile-schemas', schemadir])
```
+
+### gettext
+
+Note this example does not include `intltool` usage.
+
+`configure.ac`:
+```m4
+AM_GNU_GETTEXT([external])
+AM_GNU_GETTEXT_VERSION([0.19.7])
+
+GETTEXT_PACKAGE=foo
+AC_SUBST(GETTEXT_PACKAGE)
+AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [The prefix for our gettext translation domains.])
+```
+
+`po/Makevars`:
+```make
+XGETTEXT_OPTIONS = --from-code=UTF-8 --keyword=_ --keyword=N_ --keyword=C_:1c,2 --keyword=NC_:1c,2 --keyword=g_dngettext:2,3 --add-comments
+```
+
+`Makefile.am`:
+```make
+%.desktop: %.desktop.in
+ $(AM_V_GEN)$(MSGFMT) --desktop --template $< -d $(top_srcdir)/po -o $@
+
+%.appdata.xml: %.appdata.xml.in
+ $(AM_V_GEN)$(MSGFMT) --xml --template $< -d $(top_srcdir)/po -o $@
+```
+
+`meson.build`:
+```meson
+i18n = import('i18n')
+
+gettext_package = 'foo'
+add_project_arguments('-DGETTEXT_PACKAGE=' + gettext_package, language: 'c')
+subdir('po')
+
+i18n.merge_file(
+ input: 'foo.desktop.in',
+ output: 'foo.desktop',
+ type: 'desktop',
+ po_dir: 'po',
+ install: true,
+ install_dir: join_paths(get_option('datadir'), 'applications')
+)
+
+i18n.merge_file(
+ input: 'foo.appdata.xml.in',
+ output: 'foo.appdata.xml',
+ po_dir: 'po',
+ install: true,
+ install_dir: join_paths(get_option('datadir'), 'appdata')
+)
+```
+
+`po/meson.build`:
+```meson
+i18n.gettext(gettext_package, preset: 'glib')
+```
diff --git a/docs/markdown/Syntax.md b/docs/markdown/Syntax.md
index 09369e6..02db228 100644
--- a/docs/markdown/Syntax.md
+++ b/docs/markdown/Syntax.md
@@ -68,6 +68,16 @@ single quote = 'contains a \' character'
Similarly `\n` gets converted to a newline and `\\\\` to a single backslash.
+#### String concatenation
+
+Strings can be concatenated to form a new string using the `+` symbol.
+
+```meson
+str1 = 'abc'
+str2 = 'xyz'
+combined = str1 + '_' + str2 # combined is now abc_xyz
+```
+
#### Strings running over multiple lines
Strings running over multiple lines can be declared with three single quotes, like this:
@@ -194,19 +204,37 @@ Arrays are delimited by brackets. An array can contain an arbitrary number of ob
my_array = [1, 2, 'string', some_obj]
```
-You can add additional items to an array like this:
+Accessing elements of an array can be done via array indexing:
```meson
-my_array += [ 'foo', 3, 4, another_obj ]
+my_array = [1, 2, 'string', some_obj]
+second_element = my_array[1]
+last_element = my_array[-1]
```
+You can add more items to an array like this:
+
+```meson
+my_array += ['foo', 3, 4, another_obj]
+```
+
+When adding a single item, you do not need to enclose it in an array:
+
+```meson
+my_array += ['something']
+# This also works
+my_array += 'else'
+```
+
+Note appending to an array will always create a new array object and assign it to `my_array` instead of modifying the original since all objects in Meson are immutable.
+
#### Array methods
The following methods are defined for all arrays:
- `length`, the size of the array
- `contains`, returns `true` if the array contains the object given as argument, `false` otherwise
- - `get`, returns the object at the given index, negative indices count from the back of the array, indexing out of bounds is a fatal error
+ - `get`, returns the object at the given index, negative indices count from the back of the array, indexing out of bounds is a fatal error. Provided for backwards-compatibility, it is identical to array indexing.
Function calls
--