Permalink
Browse files

Add support for menu translations

  • Loading branch information...
1 parent cf4fa03 commit 0eae709a27a7fea7e6d2f25f50f1a5810b819319 @amoskvin amoskvin committed Oct 28, 2012
@@ -184,7 +184,7 @@ endfunction(razor_translate_ts)
#**********************************************************
-# DESCTOP files
+# DESKTOP files
#**********************************************************
function(razor_translate_desktop _RESULT)
@@ -232,6 +232,7 @@ function(razor_translate_desktop _RESULT)
file(GLOB _translations
${_translationDir}/${_fileName}_*${_fileExt}
+ ${_translationDir}/local/${_fileName}_*${_fileExt}
)
set(_pattern "'\\[.*]\\s*='")
@@ -255,10 +256,11 @@ function(razor_translate_desktop _RESULT)
set(_txFile "${CMAKE_BINARY_DIR}/tx/${_fileName}${_fileExt}.tx.sh")
string(REPLACE "${CMAKE_SOURCE_DIR}/" "" _tx_translationDir ${_translationDir})
string(REPLACE "${CMAKE_SOURCE_DIR}/" "" _tx_inFile ${_inFile})
+ string(REPLACE "." "" _fileType ${_fileExt})
file(WRITE ${_txFile}
"[ -f ${_inFile} ] || exit 0\n"
- "echo '[razor-qt.${_fileName}_desktop]'\n"
+ "echo '[razor-qt.${_fileName}_${_fileType}]'\n"
"echo 'type = DESKTOP'\n"
"echo 'source_lang = en'\n"
"echo 'source_file = ${_tx_inFile}'\n"
@@ -2,7 +2,7 @@ cmake_minimum_required( VERSION 2.6 )
set(DISTRO_MENU "")
-# for now we have onlu SUSE related custom menu
+# for now we have only SUSE related custom menu
if (EXISTS /etc/SuSE-release OR EXISTS /etc/SUSE-release OR EXISTS /etc/SuSEconfig)
message(STATUS "SUSE Linux distro detected building additional menu structure")
set(DISTRO_MENU "${DISTRO_MENU}<Menu><Name>YaST</Name><Directory>suse-yast.directory</Directory><MergeFile>yast-settings.menu</MergeFile></Menu>")
@@ -26,5 +26,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/razor-applications.menu.in
${CMAKE_CURRENT_BINARY_DIR}/razor-applications.menu
@ONLY)
+#add_subdirectory(desktop-directories)
+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/razor-applications.menu DESTINATION /etc/xdg/menus/)
install(DIRECTORY desktop-directories DESTINATION share/ PATTERN ".desktop")
@@ -0,0 +1,14 @@
+cmake_minimum_required( VERSION 2.6 )
+
+# Translations **********************************
+include(RazorTranslate)
+
+file(GLOB DIR_IN_FILES "*.directory.in")
+razor_translate_desktop(DIR_TR_FILES
+ SOURCES
+ ${DIR_IN_FILES}
+)
+
+add_custom_target(resources_directory_files ALL DEPENDS ${DIR_TR_FILES})
+
+install(FILES ${DIR_TR_FILES} DESTINATION share/desktop-directories/)
@@ -0,0 +1,43 @@
+#!/bin/bash
+#
+# Splits a desktop file containing multiple languages
+# e.g.:
+# razor-audio-video.directory
+# into:
+# razor-audio-video.directory.in
+# translations/razor-audio-video_zh_TW.directory
+# translations/razor-audio-video_uk.directory
+# ...
+
+TR_DIR=translations
+
+split_file()
+{
+ local file="$1"
+ echo "Splitting $file"
+
+ (
+ grep -v '\[\(.*\)\]\s*=' "${file}"
+ echo
+ echo "#TRANSLATIONS_DIR=${TR_DIR}"
+ echo
+ echo "# Translations"
+ ) > "${file}.in"
+
+ sed -n -e 's:.*\[\(.*\)\]\s*=.*:\1:p' "${file}" | while read lang; do
+ out="${TR_DIR}/${file%.*}_${lang}.${file##*.}"
+ (
+ cat "${file}.in"
+ grep "\[${lang}\]\s*=" "${file}"
+ ) > "$out"
+ done
+
+ rm "${file}"
+}
+
+mkdir -p "${TR_DIR}"
+
+for file in $@; do
+ split_file $1
+ shift;
+done

0 comments on commit 0eae709

Please sign in to comment.