Skip to content

Commit

Permalink
Updated template, added msg plugin and other minor changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
nvdaes committed Sep 21, 2014
1 parent 6132712 commit c35291d
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 56 deletions.
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto

# Try to ensure that po files in the repo does not include
# source code line numbers.
# Every person expected to commit po files should change their personal config file as described here:
# https://mail.gnome.org/archives/kupfer-list/2010-June/msg00002.html
*.po filter=cleanpo
5 changes: 3 additions & 2 deletions addon/globalPlugins/clipContentsDesigner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Revision and improvements: Mesar Hameed
# Date: 20/09/2014
# Added scriptCategory
# Added msg plugin, developed by Alberto Buffolino
# Date: 21/09/2014

# Append text: a global plugin for appending text to the clipboard
Expand All @@ -22,6 +23,7 @@
import api
import textInfos
import ui
import msg # Developed by Alberto Bufolino
import win32clipboard
import wx
import gui
Expand Down Expand Up @@ -156,8 +158,7 @@ def script_append(self, gesture):
return
pos = api.getReviewPosition().copy()
if self._copyStartMarker.obj != pos.obj:
# Translators: message presented when trying to append text, but the start marker doesn't reside in the current object.
ui.message(_("The start marker must reside within the same object"))
msg.message("The start marker must reside within the same object")
return
pos.move(textInfos.UNIT_CHARACTER, 1, endPoint="end")
pos.setEndPoint(self._copyStartMarker, "startToStart")
Expand Down
7 changes: 7 additions & 0 deletions addon/globalPlugins/msg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: UTF-8 -*-
#A simple module to bypass the addon translation system,
#so it can take advantage from the NVDA translations directly.
import ui

def message(message):
ui.message(_(message))
18 changes: 10 additions & 8 deletions buildVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,23 @@
# Add-on information variables
addon_info = {
# for previously unpublished addons, please follow the community guidelines at:
# https://bitbucket.org/nvdaaddonteam/todo/src/56140dbec531e4d7591338e1dbc6192f3dd422a8/guideLines.txt
# https://bitbucket.org/nvdaaddonteam/todo/raw/master/guideLines.txt
# add-on Name, internal for nvda
"addon-name" : "clipContentsDesigner",
"addon_name" : "clipContentsDesigner",
# Add-on summary, usually the user visible name of the addon.
# TRANSLATORS: Summary for this add-on to be shown on installation and add-on information.
"addon-summary" : _("Clip Contents Designer"),
# Translators: Summary for this add-on to be shown on installation and add-on information.
"addon_summary" : _("Clip Contents Designer"),
# Add-on description
# Translators: Long description to be shown for this add-on on add-on information from add-ons manager
"addon-description" : _("""Add-on for managing clipboard text."""),
"addon_description" : _("""Add-on for managing clipboard text."""),
# version
"addon-version" : "1.0-dev",
"addon_version" : "1.0-dev",
# Author(s)
"addon-author" : "Noelia <[email protected]>",
"addon_author" : u"Noelia Ruiz Martínez <[email protected]>",
# URL for the add-on documentation support
"addon-url" : "http://addons.nvda-project.org"
"addon_url" : "http://addons.nvda-project.org",
# Documentation file name
"addon_docFileName" : "readme.html",
}


Expand Down
4 changes: 2 additions & 2 deletions manifest-translated.ini.tpl
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
summary = "{addon-summary}"
description = """{addon-description}"""
summary = "{addon_summary}"
description = """{addon_description}"""
13 changes: 7 additions & 6 deletions manifest.ini.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name = {addon-name}
summary = "{addon-summary}"
description = """{addon-description}"""
author = "{addon-author}"
url = {addon-url}
version = {addon-version}
name = {addon_name}
summary = "{addon_summary}"
description = """{addon_description}"""
author = "{addon_author}"
url = {addon_url}
version = {addon_version}
docFileName = {addon_docFileName}
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Clip Contents Designer #
- Authors: Noelia.
- Authors: Noelia Ruiz Martínez.
- Download [stable version][1]
- Download [stable version][2]
- Download [development version][2]

This add-on is used to append text to the clipboard, which can be useful when you want to join sections of text together ready for pasting.
The clipboard content can also be cleared.
Expand Down
54 changes: 18 additions & 36 deletions sconstruct
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# NVDA add-on template SCONSTRUCT file
#Copyright (C) 2012 Rui Batista <[email protected]>
#Copyright (C) 2012, 2014 Rui Batista <[email protected]>
#This file is covered by the GNU General Public License.
#See the file COPYING.txt for more details.

Expand All @@ -8,15 +8,14 @@ import gettext
import os
import os.path
import zipfile
import configobj

import buildVars


def md2html(source, dest):
import markdown
lang = os.path.basename(os.path.dirname(source)).replace('_', '-')
title="{addonSummary} {addonVersion}".format(addonSummary=buildVars.addon_info["addon-summary"], addonVersion=buildVars.addon_info["addon-version"])
title="{addonSummary} {addonVersion}".format(addonSummary=buildVars.addon_info["addon_summary"], addonVersion=buildVars.addon_info["addon_version"])
headerDic = {
"[[!meta title=\"": "# ",
"\"]]": " #",
Expand Down Expand Up @@ -52,10 +51,11 @@ def mdTool(env):
)
env['BUILDERS']['markdown']=mdBuilder

env = Environment(ENV=os.environ, tools=[mdTool])

env = Environment(ENV=os.environ, tools=['gettexttool', mdTool])
env.Append(**buildVars.addon_info)

addonFile = env.File("{addon-name}-{addon-version}.nvda-addon".format(**buildVars.addon_info))
addonFile = env.File("${addon_name}-${addon_version}.nvda-addon")

def addonGenerator(target, source, env, for_signature):
action = env.Action(lambda target, source, env : createAddonBundleFromPath(source[0].abspath, target[0].abspath) and None,
Expand All @@ -79,39 +79,15 @@ env['BUILDERS']['NVDAAddon'] = Builder(generator=addonGenerator)
env['BUILDERS']['NVDAManifest'] = Builder(generator=manifestGenerator)
env['BUILDERS']['NVDATranslatedManifest'] = Builder(generator=translatedManifestGenerator)

env['BUILDERS']['gettextMoFile']=env.Builder(
action=env.Action(["msgfmt -o $TARGETS $SOURCES"], lambda t, s, e : "Compiling translation %s" % s[0]),
suffix=".mo",
src_suffix=".po"
)

env['BUILDERS']['gettextPotFile']=env.Builder(
action=env.Action(["xgettext --msgid-bugs-address='%s' --package-name='%s' --package-version='%s' -c -o $TARGETS $SOURCES" %
("[email protected]", buildVars.addon_info['addon-name'], buildVars.addon_info['addon-version'])
], lambda t, s, e : "Generating pot file %s" % t[0]),
suffix=".pot")
env['BUILDERS']['gettextMergePotFile']=env.Builder(
action=env.Action(["xgettext --msgid-bugs-address='%s' --package-name='%s' --package-version='%s' --omit-header --no-location -c -o $TARGETS $SOURCES" %
("[email protected]", buildVars.addon_info['addon-name'], buildVars.addon_info['addon-version'])
], lambda t, s, e : "Generating pot file %s" % t[0]),
suffix=".pot")

def createAddonHelp(dir):
if not os.path.isfile("docHandler.py"):
return
plugindir = os.path.join(dir, "globalPlugins")
docFilename = "{addonName}_docHandler.py".format(addonName=buildVars.addon_info["addon-name"])
docPath = os.path.join(plugindir, docFilename)
docFileTarget = env.Command(docPath, "docHandler.py", Copy("$TARGET", "$SOURCE"))
env.Depends(addon, docFileTarget)
docsDir = os.path.join(dir, "doc")
if os.path.isfile("style.css"):
cssPath = os.path.join(docsDir, "style.css")
cssTarget = env.Command(cssPath, "style.css", Copy("$TARGET", "$SOURCE"))
env.Depends(addon, cssTarget)
if os.path.isfile("README.md"):
readmePath = os.path.join(docsDir, "en", "README.md")
readmeTarget = env.Command(readmePath, "README.md", Copy("$TARGET", "$SOURCE"))
if os.path.isfile("readme.md"):
readmePath = os.path.join(docsDir, "en", "readme.md")
readmeTarget = env.Command(readmePath, "readme.md", Copy("$TARGET", "$SOURCE"))
env.Depends(addon, readmeTarget)


Expand Down Expand Up @@ -139,7 +115,7 @@ def generateManifest(source, dest):
def generateTranslatedManifest(source, language, out):
_ = gettext.translation("nvda", localedir=os.path.join("addon", "locale"), languages=[language]).ugettext
vars = {}
for var in ("addon-summary", "addon-description"):
for var in ("addon_summary", "addon_description"):
vars[var] = _(buildVars.addon_info[var])
with codecs.open(source, "r", "utf-8") as f:
manifest_template = f.read()
Expand Down Expand Up @@ -168,18 +144,24 @@ for file in pythonFiles:
env.Depends(addon, file)

#Convert markdown files to html
createAddonHelp("addon") # We need at least doc in English and should append an item to Help menu
createAddonHelp("addon") # We need at least doc in English and should enable the Help button for the add-on in Add-ons Manager
for mdFile in env.Glob(os.path.join('addon', 'doc', '*', '*.md')):
htmlFile = env.markdown(mdFile)
env.Depends(htmlFile, mdFile)
env.Depends(addon, htmlFile)

# Pot target
i18nFiles = expandGlobs(buildVars.i18nSources)
pot = env.gettextPotFile("%s.pot" % "{addon-name}".format(**buildVars.addon_info), i18nFiles)
gettextvars={
'gettext_package_bugs_address' : '[email protected]',
'gettext_package_name' : buildVars.addon_info['addon_name'],
'gettext_package_version' : buildVars.addon_info['addon_version']
}

pot = env.gettextPotFile("${addon_name}.pot", i18nFiles, **gettextvars)
env.Alias('pot', pot)
env.Depends(pot, i18nFiles)
mergePot = env.gettextMergePotFile("%s-merge.pot" % "{addon-name}".format(**buildVars.addon_info), i18nFiles)
mergePot = env.gettextMergePotFile("${addon_name}-merge.pot", i18nFiles, **gettextvars)
env.Alias('mergePot', mergePot)
env.Depends(mergePot, i18nFiles)

Expand Down
49 changes: 49 additions & 0 deletions site_scons/site_tools/gettexttool/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
""" This tool allows generation of gettext .mo compiled files, pot files from source code files
and pot files for merging.
Three new builders are added into the constructed environment:
- gettextMoFile: generates .mo file from .pot file using msgfmt.
- gettextPotFile: Generates .pot file from source code files.
- gettextMergePotFile: Creates a .pot file appropriate for merging into existing .po files.
To properly configure get text, define the following variables:
- gettext_package_bugs_address
- gettext_package_name
- gettext_package_version
"""
from SCons.Action import Action

def exists(env):
return True

XGETTEXT_COMMON_ARGS = (
"--msgid-bugs-address='$gettext_package_bugs_address' "
"--package-name='$gettext_package_name' "
"--package-version='$gettext_package_version' "
"-c -o $TARGET $SOURCES"
)

def generate(env):
env.SetDefault(gettext_package_bugs_address="[email protected]")
env.SetDefault(gettext_package_name="")
env.SetDefault(gettext_package_version="")

env['BUILDERS']['gettextMoFile']=env.Builder(
action=Action("msgfmt -o $TARGET $SOURCE", "Compiling translation $SOURCE"),
suffix=".mo",
src_suffix=".po"
)

env['BUILDERS']['gettextPotFile']=env.Builder(
action=Action("xgettext " + XGETTEXT_COMMON_ARGS, "Generating pot file $TARGET"),
suffix=".pot")

env['BUILDERS']['gettextMergePotFile']=env.Builder(
action=Action("xgettext " + "--omit-header --no-location " + XGETTEXT_COMMON_ARGS,
"Generating pot file $TARGET"),
suffix=".pot")

0 comments on commit c35291d

Please sign in to comment.