|
|
Строка 139: |
Строка 139: |
| if not isempty(frame.args['shortly']) then | | if not isempty(frame.args['shortly']) then |
| description = frame.args['shortly'] | | description = frame.args['shortly'] |
| | elseif not isempty(frame.args['translation']) then -- for term type = expression |
| | description = frame.args['translation'] |
| else | | else |
| description = frame.args['description'] | | description = frame.args['description'] |
Строка 146: |
Строка 148: |
| if not isempty(frame.args['origin']) or not isempty(frame.args['lifetime']) then | | if not isempty(frame.args['origin']) or not isempty(frame.args['lifetime']) then |
| origin = ' (' | | origin = ' (' |
| if not isempty(frame.args['lifetime']) then | | if not isempty(frame.args['origin']) then |
| origin = origin .. frame.args['lifetime'] | | origin = origin .. frame.args['origin'] |
| end | | end |
| if not isempty(frame.args['origin']) and not isempty(frame.args['lifetime']) then | | if not isempty(frame.args['origin']) and not isempty(frame.args['lifetime']) then |
| origin = origin .. ', ' | | origin = origin .. ', ' |
| end | | end |
| if not isempty(frame.args['origin']) then | | if not isempty(frame.args['lifetime']) then |
| origin = origin .. frame.args['origin'] | | origin = origin .. frame.args['lifetime'] |
| end | | end |
| origin = origin .. ')' | | origin = origin .. ')' |
Строка 176: |
Строка 178: |
| -- DEBUG | | -- DEBUG |
| --text = '<p>DEBUG: view: '.. view .."; term: ".. term .."; term to show: ".. term_to_show .."; description: ".. description .."; origin: ".. origin ..'</p>'.. text | | --text = '<p>DEBUG: view: '.. view .."; term: ".. term .."; term to show: ".. term_to_show .."; description: ".. description .."; origin: ".. origin ..'</p>'.. text |
| return text .. reference | | --return text .. reference |
| | | |
| --return frame:preprocess( text .. reference ) | | return frame:preprocess( text .. reference ) |
| end | | end |
|
| |
|
|
| |
|
| -- Invoke information from CTD about a FOREIGN EXPRESSION and shows it in footnote, pop-up or right next to expression in square brackets.
| |
| -- Used in : Шаблон:О выражении (оформление)
| |
| -- Based on: Шаблон:Иноязычное выражение БТС
| |
| -- Call example:
| |
| -- {{#invoke: CTD | expression_info
| |
| -- | expression = Foreing expression
| |
| -- | language = Language of expression
| |
| -- | origin = Origin
| |
| -- | translation= Full translation and description
| |
| -- | shortly = Short description
| |
| -- | additional = Some additional information (historical, etc.)
| |
| -- | wiki_page = Wiki page title
| |
| -- | userparam = text@view
| |
| -- }}
| |
| -- Where 'userparam' consist of:
| |
| -- text = text to show; generally it is the original text of request
| |
| -- view = style of displaying information; a language dependent parameter (consider changes in code below)
| |
| function ctd.expression_info( frame )
| |
| local expression = '<i>' .. frame.args['expression'] .. '</i>'
| |
| local short_translation = ''
| |
| local reference = ''
| |
| local language = ''
| |
| local origin = ''
| |
| local bts = ' (<i>[['.. frame.args['wiki_page'] ..'|БТС]]</i>)'
| |
|
| |
| -- split 'text@view' value of parameter 'userparam' in two variables
| |
| local i, j = string.find(frame.args['userparam'],'@',1,true)
| |
| local text = string.sub(frame.args['userparam'], 1, i-1)
| |
| local view = string.sub( string.lower(frame.args['userparam']), i+1, -1 )
| |
|
| |
| -- check if short description is specified
| |
| if not isempty(frame.args['shortly']) then
| |
| short_translation = frame.args['shortly']
| |
| elseif not isempty(frame.args['translation']) then
| |
| short_translation = frame.args['translation']
| |
| else
| |
| short_translation = frame.args['description']
| |
| end
| |
|
| |
| -- check if language specified
| |
| if not isempty(frame.args['language']) then
| |
| language = language..' ('.. frame.args['language'] .. '.)'
| |
| end
| |
|
| |
| -- check if origin specified
| |
| if not isempty(frame.args['origin']) then
| |
| origin = ' ('
| |
| if not isempty(frame.args['language']) then
| |
| origin = origin ..frame.args['language'] .. '. '
| |
| end
| |
| origin = origin .. frame.args['origin'] .. ')'
| |
| else
| |
| origin = language
| |
| end
| |
|
| |
| -- considering type of view
| |
| if view == 'подсказка' or view == 'сноска и подсказка' or view == 'подсказка и сноска' then
| |
| text = '<span style="border-bottom: 1px dotted gray; cursor: help;" title="'.. short_translation .. language ..' (БТС)">'.. text ..'</span>'
| |
| end
| |
| if view == 'сноска' or view == 'сноска и подсказка' or view == 'подсказка и сноска' then
| |
| reference = '<ref><span style="color: grey;"><i><b>' .. frame.args['expression'] .. '</b></i>' .. origin .. ' – ' .. frame.args['translation'] .. bts ..'.</span></ref>'
| |
| end
| |
| if view == 'скобки' then
| |
| text = text ..' ['.. short_translation .. language ..']'
| |
| end
| |
|
| |
| -- DEBUG.
| |
| --text = '<p>DEBUG: view: ' .. view .. "; term: " .. term .. "; description: " .. description .. "; origin: " .. origin .. '</p>' .. text
| |
| --return text .. reference ..'; view='.. view ..'; i='.. i
| |
|
| |
| return frame:preprocess( text .. reference )
| |
| end
| |
|
| |
|
| return ctd | | return ctd |