mirror of
https://github.com/swaywm/sway.git
synced 2026-04-26 06:46:26 -04:00
Support localized man pages
This commit updates meson.build to: * build and install localized man pages. Notes: Current scdoc files were moved to ease the management of locales in the future. The new doc directory in sway, swaybar, swaymsg and swaynag shall have a similar structure to that of man: where English files are kept in root dir and localized ones are nested in their respective dir.
This commit is contained in:
parent
78e6196899
commit
2ce6e4218a
1 changed files with 59 additions and 30 deletions
89
meson.build
89
meson.build
|
|
@ -93,37 +93,66 @@ conf_data.set10('HAVE_TRAY', have_tray)
|
|||
|
||||
scdoc = dependency('scdoc', version: '>=1.9.2', native: true, required: get_option('man-pages'))
|
||||
if scdoc.found()
|
||||
scdoc_prog = find_program(scdoc.get_pkgconfig_variable('scdoc'), native: true)
|
||||
sh = find_program('sh', native: true)
|
||||
mandir = get_option('mandir')
|
||||
man_files = [
|
||||
'sway/sway.1.scd',
|
||||
'sway/sway.5.scd',
|
||||
'sway/sway-bar.5.scd',
|
||||
'sway/sway-input.5.scd',
|
||||
'sway/sway-ipc.7.scd',
|
||||
'sway/sway-output.5.scd',
|
||||
'swaybar/swaybar-protocol.7.scd',
|
||||
'swaymsg/swaymsg.1.scd',
|
||||
'swaynag/swaynag.1.scd',
|
||||
'swaynag/swaynag.5.scd',
|
||||
]
|
||||
foreach filename : man_files
|
||||
topic = filename.split('.')[-3].split('/')[-1]
|
||||
section = filename.split('.')[-2]
|
||||
output = '@0@.@1@'.format(topic, section)
|
||||
scdoc_prog = find_program(scdoc.get_pkgconfig_variable('scdoc'), native: true)
|
||||
sh = find_program('sh', native: true)
|
||||
mandir = get_option('mandir')
|
||||
man_files = {
|
||||
'sway': [
|
||||
'sway.1.scd',
|
||||
'sway.5.scd',
|
||||
'sway-bar.5.scd',
|
||||
'sway-input.5.scd',
|
||||
'sway-ipc.7.scd',
|
||||
'sway-output.5.scd'
|
||||
],
|
||||
'swaybar': [
|
||||
'swaybar-protocol.7.scd'
|
||||
],
|
||||
'swaymgs': [
|
||||
'swaymsg.1.scd'
|
||||
],
|
||||
'swaynag': [
|
||||
'swaynag.1.scd',
|
||||
'swaynag.5.scd'
|
||||
]
|
||||
}
|
||||
locales = ['en']
|
||||
|
||||
custom_target(
|
||||
output,
|
||||
input: filename,
|
||||
output: output,
|
||||
command: [
|
||||
sh, '-c', '@0@ < @INPUT@ > @1@'.format(scdoc_prog.path(), output)
|
||||
],
|
||||
install: true,
|
||||
install_dir: '@0@/man@1@'.format(mandir, section)
|
||||
)
|
||||
endforeach
|
||||
foreach proj, sources: man_files
|
||||
foreach locale: locales
|
||||
if locale == 'en'
|
||||
docdir = mandir
|
||||
projdir = join_paths(meson.source_root(), proj, 'doc')
|
||||
outdir = join_paths(meson.build_root(), 'doc')
|
||||
else
|
||||
docdir = join_paths(mandir, locale)
|
||||
projdir = join_paths(meson.source_root(), proj, 'doc', locale)
|
||||
outdir = join_paths(meson.build_root(), 'doc', locale)
|
||||
endif
|
||||
|
||||
# Checks if locale dir exists before proceeding with scdoc compilation
|
||||
if run_command('[', '-d', projdir, ']').returncode() == 0
|
||||
if run_command('[', '-d', outdir, ']').returncode() != 0
|
||||
if run_command('mkdir', outdir).returncode() != 0
|
||||
warning('Failed to create directory at: @0@'.format(outdir))
|
||||
endif
|
||||
endif
|
||||
|
||||
foreach filename: sources
|
||||
input = join_paths(projdir, filename)
|
||||
if run_command('[', '-e', input, ']').returncode() == 0
|
||||
topic = input.split('.')[-3].split('/')[-1]
|
||||
section = input.split('.')[-2]
|
||||
output = '@0@/@1@.@2@'.format(outdir, topic, section)
|
||||
cmd = '@0@ < @1@ > @2@'.format(scdoc_prog.path(), input, output)
|
||||
if run_command(sh, '-c', cmd).returncode() == 0
|
||||
install_data(output, install_dir: docdir)
|
||||
endif
|
||||
endif
|
||||
endforeach
|
||||
endif
|
||||
endforeach
|
||||
endforeach
|
||||
endif
|
||||
|
||||
add_project_arguments('-DSYSCONFDIR="/@0@"'.format(join_paths(prefix, sysconfdir)), language : 'c')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue