How can I check if my react-intl messages are consistent with my en-US locale? - parsing

I want to have some type of script that will check if all the formattedMessage I have in my React components are consistent with the data I have in my en-US.json locale.
I'm using react-intl, and in my React components I use both the FormattedMessage component, as well as the formatMessage function. The FormattedMessage component is imported from react-intl, and the formatMessage function is a function from the useIntl object, which is imported from react-intl.
What is a good way to proceed with this analysis and comparison? I want to ensure that all the keys and values that exist in these FormattedMessages, match the keys and values in my en-US.json locale. This script will be run as part of my Github Workflow.
I don't know how to get started on this.

Related

Lua custom file name

In my company i've a QR reader made by Keyence with which we read codes in our production line.
The images acquired by the sensor are saved on an FTP server, and for business needs, the name of the images must be in the format: yyyymmdd_qrcodecontent.jpg.
On the sensor we already have a script in .lua that saves the images with the naming qrcodecontent.jpg.
I don't know the lua language, and from the documentation I could not find info on how to add date information
Do you have any suggestions or advice?
fmset.lua
function nameformatEvent()
local read_data
read_data = readResult():readData()
return(read_data)
end
Lua provides date and time through its os library.
https://www.lua.org/manual/5.4/manual.html#pdf-os
You can get a formatted date string through os.date.
Search the Keyence scripting manual for date and time. Run a script with print(os). If it prints nil that library is not available. At least it is not listed in the manual while some other standard libraries are.
If Keyence's scripting API does not provide the os library and no other means to get the current date and time you cannot access that information.
I'm not aware that the Keyence readers have a realtime clock on-board, so that information is probably not available on the sensor.
Get in touch with the Keyence support. That's what they're getting payed for.
You can probably use some os functions.
For the date formatting on the filename, you could write a quick function like this:
function GenerateFilename()
return os.date("%d%m%y") .. "_qrcodecontent"
end
You can probably configure a filename somewhere. I don't know what the code for readResult and :readData is, but check the content of those functions.
Just add .jpg/.jpeg to the end if it doesn't generate the file extension (change _qrcodecontent to _qrcodecontent.jpg).

Call into Lua from TI-BASIC

I have an nspire calculator and after writing a hash table implementation, found the BASIC environment to be a pretty offensive programming environment. Unfortunately, as far as I'm aware, it's impossible to use Lua to write libraries.
I did see that somewhere in the Lua interface you can detect variable changes so it might be possible within a file to use Lua functions, but I fear it will go out of scope if used externally.
Is there a better way to do this?
It's not impossible to write Lua libraries for a TI-Nspire. You can put the libraries code into a string, store it as a variable in TI-Basic and put the file in the MyLibs folder. Then, when you want to load your library, do loadstring(var.recall("libfilename/programstring"))(). This will load the library's code as a string from that files, compile it (using loadstring), and execute it (practicaly the same as require).
Also, about getting from controlling a Lua script using TI-Basic, depending on what you want to do, you could use math.eval("<some TI-Basic code>"). This will execute the code in TI-Basic, and return the result as a Lua value (or string). This way, you can call a TI-Basic function every once in a while, and act according to its output.

IBM Integration Bus and xsd:anyType

I'm working with IIB v9 mxsd message definitions. I'd like to define one of the XML elements to be of type xsd:anyType. However, in the list of types I can choose from, only anySimpleType and anyUri are possible (besides all other types like string, integer, etc.).
How can I get around this limitation?
The XMLNSC parser supports the entire XML Schema specification, including xs:any and xs:anyType. In IIBv9 you should create a Library and import your xsds into it. Link your Application to the Library and the XMLNSC parser will find and use the model. You do not need to specify the name of the Library in the node properties; the XSD model will be automatically available to the entire application.
You do not need to use a message set at all in IIBv9 and later versions.
The mxsd file format is used only by the MRM (not DFDL) parser.
You shouldn't use an MXSD to model your XML data, use a normal XSD.
MXSD is for modelling data for the DFDL parser, but you should use the XMLNSC parser for XML messages and define them in XSDs, in which you can use anyType.
As far as I know DFDL doesn't support anyType.

run-time evaluation of values in DelphiWebScript

My delphi application runs scripts using JvInterpreter (from the Jedi project).
A feature I use is runtime evaluation of expressions.
Script Example:
[...]
ShowMessage(X_SomeName);
[...]
JvInterpreter doesn't know X_SomeName.
When X_SomeName's value is required the scripter calls its OnGetValue-callback.
This points to a function I handle. There I lookup X_SomeName's value and return it.
Then JvInterpreter calls ShowMessage with the value I provided.
Now I consider switching to DelphiWebScript since it has a proper debug-interface and should also be faster than JvInterpreter.
Problem: I didn't find any obvious way to implement what JvInterpreter does with its OnGetValue/OnSetValue functions, though.
X_SomeName should be considered (and actually is, most of the time) a variable which is handled by the host application.
Any Ideas?
Thanks!
You can do that through the language extension mechanism, which has a FindUnknownName method that allows to register symbols on the spot.
It is used in the asm lib module demo, and you can also check the new "AutoExternalValues" test case in ULanguageExtensionTests, which should be closer to what you're after.

Creating macros using DWScript

I read this paragraph from the Delphi Tools Site
Changes since the last SVN update are:
Added support for FreePascal-like compile-time $INCLUDE “macros”:
%FILE% and %LINE% insert the current filename and line number into the source
%FUNCTION% inserts the current function name, or class.method name into the source
%DATE% and %TIME% allow inserting the compile date/time
Is there a way we can define macros in DWScript (other than these functions) just like people define macors in excel (using VBscript) in a simple way, where the name of the script will be the name of the function that will be used later, without adding {$Include XXX} in the executed script?
N.B.: I konw this can be done by managing the written script to be saved in a certain file called functions for ex. then save the added function with its name to be used (Add), then the user will write Add(1,2) to get the result; but my boss at work wants it to be something that looks like vbscript in excel.
I'm not sure to understand the question, so I'll list various answers to various possible interpretations...
If you want to declare functions that are implicitly supported by the scripting engine without having to "{$include}" or "uses" them, you can declare them via a TdwsUnit component, and attach it to the script component. If you don't have the "coExplicitUses" option set, they'll be available automatically, and you get design-time support in the IDE.
If you want to add internal functions (that are always there), use one of the RegisterInternalFunction overloads, you can check any of the "dwsXxxxFunctions.pas" units for examples. That's potentially more efficient, but also more cumbersome.
If you want to pre-process custom source-level macros in the source code (ala C's macros), you can use the filters functionality (check the HTML or JS filters as example of how a filter can be implemented).
If you want to react dynamically to "unknown" names, so you can declare them on the spot or bind them to something dynamically, you can use TdwsLanguageExtension.FindUnknownName, that's how the RTTI environment works f.i. (see TRTTIEnvironment in dwsRTTIConnector).
If you want to parse completely custom areas of code in a completely custom way, you can use language extensions too, override ReadInstr and check how asmLib & the JSLibModule do it to support "asm".

Resources